test: add test cases for defineProps/defineEmits

This commit is contained in:
Dunqing 2023-10-22 20:01:16 +08:00
parent eb0aa6b3a1
commit 844ec6db3b
2 changed files with 40 additions and 0 deletions

View File

@ -12,3 +12,19 @@ const array = [1, 2, 3];
<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>
"
`;

View File

@ -22,4 +22,28 @@ describe('transformSFC', () => {
})
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()
})
})