From d47672133e305f8d50b623cd96c1c1675d8b49bd Mon Sep 17 00:00:00 2001 From: lsdsjy Date: Mon, 20 Nov 2023 20:26:45 +0800 Subject: [PATCH] chore: add test --- playground/legacy/__tests__/legacy.spec.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/playground/legacy/__tests__/legacy.spec.ts b/playground/legacy/__tests__/legacy.spec.ts index 405c61f47e2700..e990fccaf321a6 100644 --- a/playground/legacy/__tests__/legacy.spec.ts +++ b/playground/legacy/__tests__/legacy.spec.ts @@ -120,11 +120,13 @@ describe.runIf(isBuild)('build', () => { const terserPattern = /^(?:!function|System.register)/ expect(findAssetFile(/chunk-async-legacy/)).toMatch(terserPattern) - expect(findAssetFile(/chunk-async\./)).not.toMatch(terserPattern) + expect(findAssetFile(/chunk-async(?!-legacy)/)).not.toMatch(terserPattern) expect(findAssetFile(/immutable-chunk-legacy/)).toMatch(terserPattern) - expect(findAssetFile(/immutable-chunk\./)).not.toMatch(terserPattern) + expect(findAssetFile(/immutable-chunk(?!-legacy)/)).not.toMatch( + terserPattern, + ) expect(findAssetFile(/index-legacy/)).toMatch(terserPattern) - expect(findAssetFile(/index\./)).not.toMatch(terserPattern) + expect(findAssetFile(/index(?!-legacy)/)).not.toMatch(terserPattern) expect(findAssetFile(/polyfills-legacy/)).toMatch(terserPattern) }) @@ -149,4 +151,11 @@ describe.runIf(isBuild)('build', () => { ), ).toBeFalsy() }) + + test.only('should have only entry files guarded', async () => { + const guard = /(import\s*\()|(import.meta)|(async\s*function\*)/ + expect(findAssetFile(/index(?!-legacy)/)).toMatch(guard) + expect(findAssetFile(/polyfills(?!-legacy)/)).toMatch(guard) + expect(findAssetFile(/index-legacy/)).not.toMatch(guard) + }) })