From 75a3d9d0ce289675794624de69512771becaf705 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Thu, 16 Jul 2026 22:26:49 +0800 Subject: [PATCH] Chore: clean up unused unit tests --- Build/lib/create-file.test.ts | 95 ------------------------------ Build/lib/create-file.ts | 2 +- Build/lib/normalize-domain.test.ts | 9 --- 3 files changed, 1 insertion(+), 105 deletions(-) delete mode 100644 Build/lib/create-file.test.ts delete mode 100644 Build/lib/normalize-domain.test.ts diff --git a/Build/lib/create-file.test.ts b/Build/lib/create-file.test.ts deleted file mode 100644 index ab99ed68..00000000 --- a/Build/lib/create-file.test.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { expect } from 'earl'; -import { fileEqual } from './create-file'; - -// eslint-disable-next-line @typescript-eslint/require-await -- async iterable -async function *createSource(input: string[]) { - for (const line of input) { - yield line; - } -} - -async function test(a: string[], b: string[], expected: boolean) { - expect((await fileEqual(a, createSource(b)))).toEqual(expected); -} - -describe('fileEqual', () => { - it('same', () => test( - ['A', 'B'], - ['A', 'B'], - true - )); - - it('ignore comment 1', async () => { - await test( - ['# A', 'B'], - ['# B', 'B'], - true - ); - }); - - it('ignore comment 2', () => test( - ['# A', '# C', 'B'], - ['# A', '# D', 'B'], - true - )); - - it('ignore comment 3', () => test( - ['# A', '# C', 'B'], - ['# A', '# D', 'A'], - false - )); - - it('comment more', () => test( - ['# A', 'B'], - ['# A', '# B', 'B'], - false - )); - - it('comment less', () => test( - ['# A', '# B', 'B'], - ['# A', 'B'], - false - )); - - it('larger', () => test( - ['A', 'B'], - ['A', 'B', 'C'], - false - )); - - it('smaller', () => test( - ['A', 'B', 'C'], - ['A', 'B'], - false - )); - - it('eol more #1', () => test( - ['A', 'B'], - ['A', 'B', ''], - false - )); - - it('eol more #2', () => test( - ['A', 'B', ''], - ['A', 'B', '', ''], - false - )); - - it('eol less #1', () => test( - ['A', 'B', ''], - ['A', 'B'], - false - )); - - it('eol less #2', () => test( - ['A', 'B', '', ''], - ['A', 'B', ''], - false - )); - - it('sgmodule', () => test( - ['#!name=[Sukka] URL Redirect', '#!desc=Last Updated: 2025-04-21T13:01:42.570Z Size: 127', '', 'always-real-ip'], - ['#!name=[Sukka] URL Redirect', '#!desc=Last Updated: 2025-04-20T13:01:42.570Z Size: 130', '', 'always-real-ip'], - true - )); -}); diff --git a/Build/lib/create-file.ts b/Build/lib/create-file.ts index d2bf3280..69a7fffb 100644 --- a/Build/lib/create-file.ts +++ b/Build/lib/create-file.ts @@ -8,7 +8,7 @@ import { writeFile } from './misc'; import { createCompareSource, fileEqualWithCommentComparator } from 'foxts/compare-source'; import { promisify } from 'node:util'; -export const fileEqual = createCompareSource(fileEqualWithCommentComparator); +const fileEqual = createCompareSource(fileEqualWithCommentComparator); export async function compareAndWriteFile(span: Span, linesA: string[], filePath: string) { // readFileByLine will not include last empty line. So we always pop the linesA for comparison purpose diff --git a/Build/lib/normalize-domain.test.ts b/Build/lib/normalize-domain.test.ts deleted file mode 100644 index 63d1658e..00000000 --- a/Build/lib/normalize-domain.test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { describe, it } from 'mocha'; - -import { normalizeDomain } from './normalize-domain'; - -describe('normalizeDomain', () => { - it('mine.torrent.pw', () => { - console.log(normalizeDomain('mine.torrent.pw')); - }); -});