Files
shadcn-ui/packages/shadcn/test/utils/get-item-target-path.test.ts
shadcn 254198b4bf feat: add shadcn/registry (#6339)
* feat: implement shadcn/registry

* feat: add schema field

* fix: import

* chore: add changeset

* chore: remove console

* fix: tests

* fix: diff command

* feat: move to schema/registy-item.json

* fix

* ci: switch to node 20

* ci: build packages
2025-01-14 10:50:19 +04:00

40 lines
1.1 KiB
TypeScript

import path from "path"
import { expect, test } from "vitest"
import { getItemTargetPath } from "../../src/registry/api"
import { getConfig } from "../../src/utils/get-config"
test("get item target path", async () => {
// Full config.
let appDir = path.resolve(__dirname, "../fixtures/config-full")
expect(
await getItemTargetPath(await getConfig(appDir), {
type: "registry:ui",
})
).toEqual(path.resolve(appDir, "./src/ui"))
// Partial config.
appDir = path.resolve(__dirname, "../fixtures/config-partial")
expect(
await getItemTargetPath(await getConfig(appDir), {
type: "registry:ui",
})
).toEqual(path.resolve(appDir, "./components/ui"))
// JSX.
appDir = path.resolve(__dirname, "../fixtures/config-jsx")
expect(
await getItemTargetPath(await getConfig(appDir), {
type: "registry:ui",
})
).toEqual(path.resolve(appDir, "./components/ui"))
// Custom paths.
appDir = path.resolve(__dirname, "../fixtures/config-ui")
expect(
await getItemTargetPath(await getConfig(appDir), {
type: "registry:ui",
})
).toEqual(path.resolve(appDir, "./src/ui"))
})