mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-15 20:01:35 +00:00
* feat(cli): add support for custom ui dir * docs(www): update docs for aliases.ui * chore: add changeset
121 lines
2.9 KiB
TypeScript
121 lines
2.9 KiB
TypeScript
import { expect, test } from "vitest"
|
|
|
|
import { transform } from "../../src/utils/transformers"
|
|
|
|
test("transform import", async () => {
|
|
expect(
|
|
await transform({
|
|
filename: "test.ts",
|
|
raw: `import * as React from "react"
|
|
import { Foo } from "bar"
|
|
import { Button } from "@/registry/new-york/ui/button"
|
|
import { Label} from "ui/label"
|
|
import { Box } from "@/registry/new-york/box"
|
|
|
|
import { cn } from "@/lib/utils"
|
|
`,
|
|
config: {
|
|
tsx: true,
|
|
tailwind: {
|
|
baseColor: "neutral",
|
|
cssVariables: true,
|
|
},
|
|
aliases: {
|
|
components: "@/components",
|
|
utils: "@/lib/utils",
|
|
},
|
|
},
|
|
})
|
|
).toMatchSnapshot()
|
|
|
|
expect(
|
|
await transform({
|
|
filename: "test.ts",
|
|
raw: `import * as React from "react"
|
|
import { Foo } from "bar"
|
|
import { Button } from "@/registry/new-york/ui/button"
|
|
import { Label} from "ui/label"
|
|
import { Box } from "@/registry/new-york/box"
|
|
|
|
import { cn, foo, bar } from "@/lib/utils"
|
|
import { bar } from "@/lib/utils/bar"
|
|
`,
|
|
config: {
|
|
tsx: true,
|
|
aliases: {
|
|
components: "~/src/components",
|
|
utils: "~/lib",
|
|
},
|
|
},
|
|
})
|
|
).toMatchSnapshot()
|
|
|
|
expect(
|
|
await transform({
|
|
filename: "test.ts",
|
|
raw: `import * as React from "react"
|
|
import { Foo } from "bar"
|
|
import { Button } from "@/registry/new-york/ui/button"
|
|
import { Label} from "ui/label"
|
|
import { Box } from "@/registry/new-york/box"
|
|
|
|
import { cn } from "@/lib/utils"
|
|
import { bar } from "@/lib/utils/bar"
|
|
`,
|
|
config: {
|
|
tsx: true,
|
|
aliases: {
|
|
components: "~/src/components",
|
|
utils: "~/src/utils",
|
|
},
|
|
},
|
|
})
|
|
).toMatchSnapshot()
|
|
|
|
expect(
|
|
await transform({
|
|
filename: "test.ts",
|
|
raw: `import * as React from "react"
|
|
import { Foo } from "bar"
|
|
import { Button } from "@/registry/new-york/ui/button"
|
|
import { Label} from "ui/label"
|
|
import { Box } from "@/registry/new-york/box"
|
|
|
|
import { cn } from "@/lib/utils"
|
|
import { bar } from "@/lib/utils/bar"
|
|
`,
|
|
config: {
|
|
tsx: true,
|
|
aliases: {
|
|
components: "~/src/components",
|
|
utils: "~/src/utils",
|
|
ui: "~/src/components",
|
|
},
|
|
},
|
|
})
|
|
).toMatchSnapshot()
|
|
|
|
expect(
|
|
await transform({
|
|
filename: "test.ts",
|
|
raw: `import * as React from "react"
|
|
import { Foo } from "bar"
|
|
import { Button } from "@/registry/new-york/ui/button"
|
|
import { Label} from "ui/label"
|
|
import { Box } from "@/registry/new-york/box"
|
|
|
|
import { cn } from "@/lib/utils"
|
|
import { bar } from "@/lib/utils/bar"
|
|
`,
|
|
config: {
|
|
tsx: true,
|
|
aliases: {
|
|
components: "~/src/components",
|
|
utils: "~/src/utils",
|
|
ui: "~/src/ui",
|
|
},
|
|
},
|
|
})
|
|
).toMatchSnapshot()
|
|
})
|