test: add test to check all type references

This commit is contained in:
zernonia 2024-05-21 12:35:46 +08:00
parent eb68fd42d9
commit f3afcba31e
2 changed files with 48 additions and 0 deletions

View File

@ -60,3 +60,27 @@ const props = defineProps({
</script> </script>
" "
`; `;
exports[`transformSFC > remove all type reference 1`] = `
"<script setup>
const array = [1, 2, 3];
</script>
<template>
<div
v-bind=\\"{ array }\\"
:prop=\\"(a) => a\\"
:prop2=\\"
(a) => {
let b = a;
return b;
}
\\"
>
{{ true ? 123 : 0 }}
</div>
</template>
<style scoped></style>
"
`;

View File

@ -24,6 +24,30 @@ describe('transformSFC', () => {
expect(result).toMatchSnapshot() expect(result).toMatchSnapshot()
}) })
it('remove all type reference', async () => {
const result = await transform({
filename: 'app.vue',
raw: `<script lang="ts" setup>
const array: (number | string)[] = [1, 2, 3]
</script>
<template>
<div v-bind="{ array }" :prop="(a: number) => a" :prop2="(a: number) => {
let b: number = a
return b
}">
{{ true ? 123 as number : 0 }}
</div>
</template>
<style scoped>
</style>
`,
config: {},
})
expect(result).toMatchSnapshot()
})
it('defineProps', async () => { it('defineProps', async () => {
const result = await transform({ const result = await transform({
filename: 'app.vue', filename: 'app.vue',