From 18ca80bb1b2047f2f54131f99d5c052cfaaec40d Mon Sep 17 00:00:00 2001 From: keven1024 Date: Thu, 9 Apr 2026 10:34:37 +0800 Subject: [PATCH] feat(front): add Vitest configuration and unit tests for calcFileHash to ensure consistency between native and wasm engines --- front/{lib => tests/utils}/calcFileHash.test.ts | 2 +- front/vitest.config.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) rename front/{lib => tests/utils}/calcFileHash.test.ts (96%) create mode 100644 front/vitest.config.ts diff --git a/front/lib/calcFileHash.test.ts b/front/tests/utils/calcFileHash.test.ts similarity index 96% rename from front/lib/calcFileHash.test.ts rename to front/tests/utils/calcFileHash.test.ts index ac0c8c5..5f4e796 100644 --- a/front/lib/calcFileHash.test.ts +++ b/front/tests/utils/calcFileHash.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest' -import calcFileHash from './calcFileHash' +import calcFileHash from '@/lib/calcFileHash' const makeFile = (content: string) => new File([content], 'test.txt', { type: 'text/plain' }) diff --git a/front/vitest.config.ts b/front/vitest.config.ts new file mode 100644 index 0000000..9475829 --- /dev/null +++ b/front/vitest.config.ts @@ -0,0 +1,15 @@ +import { fileURLToPath, URL } from 'node:url' +import { defineConfig } from 'vitest/config' + +const rootDir = fileURLToPath(new URL('./', import.meta.url)) + +export default defineConfig({ + resolve: { + alias: [ + { find: /^@\/(.*)$/, replacement: `${rootDir}$1` }, + { find: /^~\/(.*)$/, replacement: `${rootDir}$1` }, + { find: /^@@\/(.*)$/, replacement: `${rootDir}$1` }, + { find: /^~~\/(.*)$/, replacement: `${rootDir}$1` }, + ], + }, +})