test: update

This commit is contained in:
Dunqing 2023-09-13 18:21:27 +08:00
parent e161ec546d
commit 32ab678017
3 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,12 @@
<script lang="ts" setup>
const array: (number | string)[] = [1, 2, 3]
</script>
<template>
<div v-bind="{ array }">
template
</div>
</template>
<style scoped>
</style>

View File

@ -0,0 +1,14 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`transformSFC > basic 1`] = `
"<script setup>
const array = [1, 2, 3];
</script>
<template>
<div v-bind=\\"{ array }\\">template</div>
</template>
<style scoped></style>
"
`;

View File

@ -0,0 +1,18 @@
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import { describe, expect, test } from 'vitest'
import { transformSFC } from '../../src/utils/transformers/transform-sfc'
describe('transformSFC', () => {
const appVuePath = resolve(__dirname, '../fixtures/transform-sfc/app.vue')
const content = readFileSync(appVuePath, 'utf-8')
test('basic', async () => {
const result = await transformSFC({
name: 'app.vue',
content,
}, {
typescript: false,
} as any)
expect(result).toMatchSnapshot()
})
})