resolve-import.test.ts — ui Source File
Architecture documentation for resolve-import.test.ts, a typescript file in the ui codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 4e49f512_dcdd_3ee6_bfc7_bcdbf0744470["resolve-import.test.ts"] 70cebd90_e1ca_0894_14cb_90518707c85e["resolve-import.ts"] 4e49f512_dcdd_3ee6_bfc7_bcdbf0744470 --> 70cebd90_e1ca_0894_14cb_90518707c85e cb3cad0a_32e1_1d9f_e4fd_f805366a6df8["resolveImport"] 4e49f512_dcdd_3ee6_bfc7_bcdbf0744470 --> cb3cad0a_32e1_1d9f_e4fd_f805366a6df8 d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5["path"] 4e49f512_dcdd_3ee6_bfc7_bcdbf0744470 --> d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5 67c3fcb7_babc_5ba5_b887_30779f599239["tsconfig-paths"] 4e49f512_dcdd_3ee6_bfc7_bcdbf0744470 --> 67c3fcb7_babc_5ba5_b887_30779f599239 c8d55bee_7008_1e1f_317b_8dc47b31b6a8["vitest"] 4e49f512_dcdd_3ee6_bfc7_bcdbf0744470 --> c8d55bee_7008_1e1f_317b_8dc47b31b6a8 style 4e49f512_dcdd_3ee6_bfc7_bcdbf0744470 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import path from "path"
import { loadConfig, type ConfigLoaderSuccessResult } from "tsconfig-paths"
import { expect, test } from "vitest"
import { resolveImport } from "../../src/utils/resolve-import"
test("resolve import", async () => {
expect(
await resolveImport("@/foo/bar", {
absoluteBaseUrl: "/Users/shadcn/Projects/foobar",
paths: {
"@/*": ["./src/*"],
"~/components/*": ["./src/components/*"],
"~/lib": ["./src/lib"],
},
})
).toEqual("/Users/shadcn/Projects/foobar/src/foo/bar")
expect(
await resolveImport("~/components/foo/bar/baz", {
absoluteBaseUrl: "/Users/shadcn/Projects/foobar",
paths: {
"@/*": ["./src/*"],
"~/components/*": ["./src/components/*"],
"~/lib": ["./src/lib"],
},
})
).toEqual("/Users/shadcn/Projects/foobar/src/components/foo/bar/baz")
expect(
await resolveImport("components/foo/bar", {
absoluteBaseUrl: "/Users/shadcn/Projects/foobar",
paths: {
"components/*": ["./src/app/components/*"],
"ui/*": ["./src/ui/primities/*"],
lib: ["./lib"],
},
})
).toEqual("/Users/shadcn/Projects/foobar/src/app/components/foo/bar")
expect(
await resolveImport("lib/utils", {
absoluteBaseUrl: "/Users/shadcn/Projects/foobar",
paths: {
"components/*": ["./src/app/components/*"],
"ui/*": ["./src/ui/primities/*"],
lib: ["./lib"],
},
})
).toEqual("/Users/shadcn/Projects/foobar/lib/utils")
})
test("resolve import with base url", async () => {
const cwd = path.resolve(__dirname, "../fixtures/with-base-url")
const config = (await loadConfig(cwd)) as ConfigLoaderSuccessResult
expect(await resolveImport("@/components/ui", config)).toEqual(
path.resolve(cwd, "components/ui")
)
expect(await resolveImport("@/lib/utils", config)).toEqual(
path.resolve(cwd, "lib/utils")
)
expect(await resolveImport("foo/bar", config)).toEqual(
path.resolve(cwd, "foo/bar")
)
})
test("resolve import without base url", async () => {
const cwd = path.resolve(__dirname, "../fixtures/without-base-url")
const config = (await loadConfig(cwd)) as ConfigLoaderSuccessResult
expect(await resolveImport("~/components/ui", config)).toEqual(
path.resolve(cwd, "components/ui")
)
expect(await resolveImport("~/lib/utils", config)).toEqual(
path.resolve(cwd, "lib/utils")
)
expect(await resolveImport("foo/bar", config)).toEqual(
path.resolve(cwd, "foo/bar")
)
})
Domain
Dependencies
- path
- resolve-import.ts
- resolveImport
- tsconfig-paths
- vitest
Source
Frequently Asked Questions
What does resolve-import.test.ts do?
resolve-import.test.ts is a source file in the ui codebase, written in typescript. It belongs to the FrameworkTooling domain.
What does resolve-import.test.ts depend on?
resolve-import.test.ts imports 5 module(s): path, resolve-import.ts, resolveImport, tsconfig-paths, vitest.
Where is resolve-import.test.ts in the architecture?
resolve-import.test.ts is located at packages/shadcn/test/utils/resolve-import.test.ts (domain: FrameworkTooling, directory: packages/shadcn/test/utils).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free