Skip to content

Commit a976c24

Browse files
committed
test: case for cache key conflict
1 parent e2598b9 commit a976c24

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

packages/compiler-sfc/__tests__/parse.spec.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ h1 { color: red }
360360
})
361361

362362
// This only tests if the "source to sfc" cache has "defaultScriptLang" as part of the cache key.
363-
test('source cache key', () => {
363+
test('different source cache key', () => {
364364
// The same SFC as previous test
365365
const { descriptor, errors } = parse(
366366
`
@@ -375,5 +375,29 @@ h1 { color: red }
375375
expect(descriptor.script?.lang).toBe('tsx')
376376
expect(descriptor.scriptSetup?.lang).toBe('tsx')
377377
})
378+
379+
test('source cache key conflict', () => {
380+
expect(
381+
parse(
382+
`
383+
<script>console.log(0x010)</script>
384+
<script setup>console.log(0x011)</script>
385+
`,
386+
{
387+
defaultScriptLang: ''
388+
}
389+
).errors.length
390+
).toBe(0)
391+
392+
const { descriptor, errors } = parse(
393+
`
394+
<script>console.log(0x010)</script>
395+
<script setup>console.log(0x011)</script>
396+
`
397+
)
398+
expect(errors.length).toBe(0)
399+
expect(descriptor.script?.lang).toBeUndefined()
400+
expect(descriptor.scriptSetup?.lang).toBeUndefined()
401+
})
378402
})
379403
})

0 commit comments

Comments
 (0)