test: add test cases for defineProps/defineEmits
This commit is contained in:
parent
eb0aa6b3a1
commit
844ec6db3b
|
|
@ -12,3 +12,19 @@ const array = [1, 2, 3];
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`transformSFC > defineEmits 1`] = `
|
||||||
|
"<script setup>
|
||||||
|
const emit = defineEmits([\\"foo\\"]);
|
||||||
|
</script>
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`transformSFC > defineProps 1`] = `
|
||||||
|
"<script setup>
|
||||||
|
const props = defineProps({
|
||||||
|
foo: { type: String, required: true },
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
"
|
||||||
|
`;
|
||||||
|
|
|
||||||
|
|
@ -22,4 +22,28 @@ describe('transformSFC', () => {
|
||||||
})
|
})
|
||||||
expect(result).toMatchSnapshot()
|
expect(result).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('defineProps', async () => {
|
||||||
|
const result = await transform({
|
||||||
|
filename: 'app.vue',
|
||||||
|
raw: `<script lang="ts" setup>
|
||||||
|
const props = defineProps<{ foo: string }>()
|
||||||
|
</script>
|
||||||
|
`,
|
||||||
|
config: {},
|
||||||
|
})
|
||||||
|
expect(result).toMatchSnapshot()
|
||||||
|
})
|
||||||
|
|
||||||
|
test('defineEmits', async () => {
|
||||||
|
const result = await transform({
|
||||||
|
filename: 'app.vue',
|
||||||
|
raw: `<script lang="ts" setup>
|
||||||
|
const emit = defineEmits<{ foo: string }>()
|
||||||
|
</script>
|
||||||
|
`,
|
||||||
|
config: {},
|
||||||
|
})
|
||||||
|
expect(result).toMatchSnapshot()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user