File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
packages/compiler-sfc/__tests__ Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -319,5 +319,32 @@ h1 { color: red }
319
319
`At least one <template> or <script> is required in a single file component`
320
320
)
321
321
} )
322
+
323
+ test ( 'different default lang for script & script setup' , ( ) => {
324
+ const { descriptor, errors } = parse (
325
+ `<script setup>const foo: string = 'bar'</script>
326
+ <script>console.log(1)</script>` ,
327
+ {
328
+ defaultScriptLang : 'ts' ,
329
+ defaultScriptSetupLang : 'tsx'
330
+ }
331
+ )
332
+ expect ( errors . length ) . toBe ( 0 )
333
+ expect ( descriptor . script ?. lang ) . toBe ( 'ts' )
334
+ expect ( descriptor . scriptSetup ?. lang ) . toBe ( 'tsx' )
335
+ } )
336
+
337
+ test ( 'the same default lang for script & script setup' , ( ) => {
338
+ const { descriptor, errors } = parse (
339
+ `<script setup>const foo: string = 'bar'</script>
340
+ <script>console.log(1)</script>` ,
341
+ {
342
+ defaultScriptLang : 'ts'
343
+ }
344
+ )
345
+ expect ( errors . length ) . toBe ( 0 )
346
+ expect ( descriptor . script ?. lang ) . toBe ( 'ts' )
347
+ expect ( descriptor . scriptSetup ?. lang ) . toBe ( 'ts' )
348
+ } )
322
349
} )
323
350
} )
You can’t perform that action at this time.
0 commit comments