From 9826a7a6f4ada19c0c255f3536f67e47b2b22d88 Mon Sep 17 00:00:00 2001 From: hemengke <23536175@qq.com> Date: Fri, 31 May 2024 16:34:16 +0800 Subject: [PATCH] ci: test --- playground/spa/vite.config.ts | 2 +- tests/utils.test.ts | 22 +++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/playground/spa/vite.config.ts b/playground/spa/vite.config.ts index 3dea408..15ccefb 100644 --- a/playground/spa/vite.config.ts +++ b/playground/spa/vite.config.ts @@ -18,7 +18,7 @@ export default defineConfig(() => ({ plugins: [ react(), publicTypescript({ - outputDir: '/out', + outputDir: 'out', destination: 'memory', babel: true, }), diff --git a/tests/utils.test.ts b/tests/utils.test.ts index 6305b1b..48885c9 100644 --- a/tests/utils.test.ts +++ b/tests/utils.test.ts @@ -6,17 +6,15 @@ import { eq, extractHashFromFileName, getContentHash, isPublicTypescript, linebr describe('unit test', () => { test('should return true when filePath is a public typescript file', () => { - const filePath = 'src/foo/bar.ts' - const root = 'src' - const inputDir = 'foo' - expect(isPublicTypescript({ filePath, inputDir, root })).toBe(true) + const filePath = '/src/foo/bar.ts' + const inputDir = '/src/foo' + expect(isPublicTypescript({ filePath, inputDir })).toBe(true) }) test('should return false when filePath is not a public typescript file', () => { - const filePath = 'src/foo/bar.js' - const root = 'src' - const inputDir = 'foo' - expect(isPublicTypescript({ filePath, inputDir, root })).toBe(false) + const filePath = '/src/foo/bar.js' + const inputDir = '/src/foo' + expect(isPublicTypescript({ filePath, inputDir })).toBe(false) }) test('should be typescript file', () => { @@ -24,15 +22,13 @@ describe('unit test', () => { const tsFile = 'hello.ts' const otherFile = 'hello.js' const res1 = isPublicTypescript({ - filePath: path.resolve(root, `public-typescript/${tsFile}`), - inputDir: 'public-typescript', - root, + filePath: path.join(root, `public-typescript/${tsFile}`), + inputDir: path.join(root, 'public-typescript'), }) const res2 = isPublicTypescript({ filePath: path.resolve(root, `public-typescript/${otherFile}`), - inputDir: 'public-typescript', - root, + inputDir: path.join(root, 'public-typescript'), }) expect(res1).toBe(true)