shadcn-vue/packages/cli/test/utils/transform-import.test.ts
2023-09-19 00:30:11 +08:00

68 lines
1.7 KiB
TypeScript

import { expect, test } from 'vitest'
import { transform } from '../../src/utils/transformers'
test('transform import', async () => {
expect(
await transform({
filename: 'app.vue',
raw: `import { Foo } from "bar"
import { Button } from "@/lib/registry/new-york/ui/button"
import { Label} from "ui/label"
import { Box } from "@/lib/registry/new-york/box"
import { cn } from "@/lib/utils"
`,
config: {
tailwind: {
baseColor: 'neutral',
cssVariables: true,
},
aliases: {
components: '@/components',
utils: '@/lib/utils',
},
},
}),
).toMatchSnapshot()
expect(
await transform({
filename: 'app.vue',
raw: `import { Foo } from "bar"
import { Button } from "@/lib/registry/new-york/ui/button"
import { Label} from "ui/label"
import { Box } from "@/lib/registry/new-york/box"
import { cn, foo, bar } from "@/lib/utils"
import { bar } from "@/lib/utils/bar"
`,
config: {
aliases: {
components: '~/src/components',
utils: '~/lib',
},
},
}),
).toMatchSnapshot()
expect(
await transform({
filename: 'app.vue',
raw: `import { Foo } from "bar"
import { Button } from "@/lib/registry/new-york/ui/button"
import { Label} from "ui/label"
import { Box } from "@/lib/registry/new-york/box"
import { cn } from "@/lib/utils"
import { bar } from "@/lib/utils/bar"
`,
config: {
aliases: {
components: '~/src/components',
utils: '~/src/utils',
},
},
}),
).toMatchSnapshot()
})