Skip to content

Commit

Permalink
test: add
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Jan 26, 2023
1 parent e30b4cf commit be78301
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,21 @@ return () => {}
}"
`;

exports[`SFC compile <script setup> > should compile JS syntax 1`] = `
"export default {
setup(__props, { expose }) {
expose();

const a = 1
const b = 2
const c = 3

return { a, b, c }
}

}"
`;

exports[`SFC compile <script setup> > should expose top level declarations 1`] = `
"import { x } from './x'

Expand Down
12 changes: 12 additions & 0 deletions packages/compiler-sfc/__tests__/compileScript.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ import { BindingTypes } from '@vue/compiler-core'
import { compileSFCScript as compile, assertCode, mockId } from './utils'

describe('SFC compile <script setup>', () => {
test('should compile JS syntax', () => {
const { content } = compile(`
<script setup lang='js'>
const a = 1
const b = 2
const c = 3
</script>
`)
expect(content).toMatch(`return { a, b, c }`)
assertCode(content)
})

test('should expose top level declarations', () => {
const { content, bindings } = compile(`
<script setup>
Expand Down

0 comments on commit be78301

Please sign in to comment.