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 dcb4037 commit d6edcea
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Expand Up @@ -739,6 +739,24 @@ return { a, props, emit }
}"
`;

exports[`SFC compile <script setup> > defineProps/defineEmits in multi-variable declaration fix #7422 1`] = `
"export default {
props: ['item'],
emits: ['foo'],
setup(__props, { expose, emit: emits }) {
expose();

const props = __props;

const a = 0,
b = 0;

return { props, emits, a, b }
}

}"
`;

exports[`SFC compile <script setup> > dev mode import usage check > TS annotations 1`] = `
"import { defineComponent as _defineComponent } from 'vue'
import { Foo, Bar, Baz, Qux, Fred } from './x'
Expand Down
17 changes: 17 additions & 0 deletions packages/compiler-sfc/__tests__/compileScript.spec.ts
Expand Up @@ -160,6 +160,23 @@ const myEmit = defineEmits(['foo', 'bar'])
expect(content).toMatch(`emits: ['a'],`)
})

// #7422
test('defineProps/defineEmits in multi-variable declaration fix #7422', () => {
const { content } = compile(`
<script setup>
const props = defineProps(['item']),
emits = defineEmits(['foo']),
a = 0,
b = 0;
</script>
`)
assertCode(content)
expect(content).toMatch(`props: ['item'],`)
expect(content).toMatch(`emits: ['foo'],`)
expect(content).toMatch(`const a = 0,`)
expect(content).toMatch(`b = 0;`)
})

test('defineProps/defineEmits in multi-variable declaration (full removal)', () => {
const { content } = compile(`
<script setup>
Expand Down

0 comments on commit d6edcea

Please sign in to comment.