Skip to content

Commit

Permalink
chore: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
lsdsjy committed Nov 20, 2023
1 parent c339377 commit d476721
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions playground/legacy/__tests__/legacy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})

Expand All @@ -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)
})
})

0 comments on commit d476721

Please sign in to comment.