mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-23 04:35:46 +00:00
* feat(cli): add support for custom ui dir * docs(www): update docs for aliases.ui * chore: add changeset
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import path from "path"
|
|
import { expect, test } from "vitest"
|
|
|
|
import { getConfig } from "../../src/utils/get-config"
|
|
import { getItemTargetPath } from "../../src/utils/registry"
|
|
|
|
test("get item target path", async () => {
|
|
// Full config.
|
|
let appDir = path.resolve(__dirname, "../fixtures/config-full")
|
|
expect(
|
|
await getItemTargetPath(await getConfig(appDir), {
|
|
type: "components:ui",
|
|
})
|
|
).toEqual(path.resolve(appDir, "./src/components/ui"))
|
|
|
|
// Partial config.
|
|
appDir = path.resolve(__dirname, "../fixtures/config-partial")
|
|
expect(
|
|
await getItemTargetPath(await getConfig(appDir), {
|
|
type: "components:ui",
|
|
})
|
|
).toEqual(path.resolve(appDir, "./components/ui"))
|
|
|
|
// JSX.
|
|
appDir = path.resolve(__dirname, "../fixtures/config-jsx")
|
|
expect(
|
|
await getItemTargetPath(await getConfig(appDir), {
|
|
type: "components:ui",
|
|
})
|
|
).toEqual(path.resolve(appDir, "./components/ui"))
|
|
|
|
// Custom paths.
|
|
appDir = path.resolve(__dirname, "../fixtures/config-ui")
|
|
expect(
|
|
await getItemTargetPath(await getConfig(appDir), {
|
|
type: "components:ui",
|
|
})
|
|
).toEqual(path.resolve(appDir, "./src/ui"))
|
|
})
|