Skip to content

Commit fa37ca9

Browse files
committed
test: add
1 parent 3385107 commit fa37ca9

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap

+15
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,21 @@ return () => {}
12771277
}"
12781278
`;
12791279

1280+
exports[`SFC compile <script setup> > should compile JS syntax 1`] = `
1281+
"export default {
1282+
setup(__props, { expose }) {
1283+
expose();
1284+
1285+
const a = 1
1286+
const b = 2
1287+
const c = 3
1288+
1289+
return { a, b, c }
1290+
}
1291+
1292+
}"
1293+
`;
1294+
12801295
exports[`SFC compile <script setup> > should expose top level declarations 1`] = `
12811296
"import { x } from './x'
12821297

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

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ import { BindingTypes } from '@vue/compiler-core'
22
import { compileSFCScript as compile, assertCode, mockId } from './utils'
33

44
describe('SFC compile <script setup>', () => {
5+
test('should compile JS syntax', () => {
6+
const { content } = compile(`
7+
<script setup lang='js'>
8+
const a = 1
9+
const b = 2
10+
const c = 3
11+
</script>
12+
`)
13+
expect(content).toMatch(`return { a, b, c }`)
14+
assertCode(content)
15+
})
16+
517
test('should expose top level declarations', () => {
618
const { content, bindings } = compile(`
719
<script setup>

0 commit comments

Comments
 (0)