Home / File/ add-registries.test.ts — ui Source File

add-registries.test.ts — ui Source File

Architecture documentation for add-registries.test.ts, a typescript file in the ui codebase. 3 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  f6f5cf14_e6a1_39ed_ff02_387d541b5757["add-registries.test.ts"]
  670848eb_ec36_f11f_b3df_91f7406ddb11["add.ts"]
  f6f5cf14_e6a1_39ed_ff02_387d541b5757 --> 670848eb_ec36_f11f_b3df_91f7406ddb11
  74101798_277e_166d_5b6a_840713359dd0["parseRegistryArg"]
  f6f5cf14_e6a1_39ed_ff02_387d541b5757 --> 74101798_277e_166d_5b6a_840713359dd0
  c8d55bee_7008_1e1f_317b_8dc47b31b6a8["vitest"]
  f6f5cf14_e6a1_39ed_ff02_387d541b5757 --> c8d55bee_7008_1e1f_317b_8dc47b31b6a8
  style f6f5cf14_e6a1_39ed_ff02_387d541b5757 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { describe, expect, it } from "vitest"

import { parseRegistryArg } from "../../src/commands/registry/add"

describe("parseRegistryArg", () => {
  it("should parse namespace without URL", () => {
    expect(parseRegistryArg("@magicui")).toEqual({ namespace: "@magicui" })
    expect(parseRegistryArg("@aceternity")).toEqual({ namespace: "@aceternity" })
  })

  it("should parse namespace with URL", () => {
    expect(
      parseRegistryArg("@mycompany=https://example.com/r/{name}.json")
    ).toEqual({
      namespace: "@mycompany",
      url: "https://example.com/r/{name}.json",
    })
  })

  it("should handle URL with query params containing =", () => {
    expect(
      parseRegistryArg("@foo=https://example.com/r/{name}.json?token=abc")
    ).toEqual({
      namespace: "@foo",
      url: "https://example.com/r/{name}.json?token=abc",
    })
  })

  it("should handle URL with multiple = in query params", () => {
    expect(
      parseRegistryArg(
        "@bar=https://example.com/r/{name}.json?token=abc&key=xyz"
      )
    ).toEqual({
      namespace: "@bar",
      url: "https://example.com/r/{name}.json?token=abc&key=xyz",
    })
  })

  it("should handle URL with port number", () => {
    expect(
      parseRegistryArg("@local=http://localhost:8080/r/{name}.json")
    ).toEqual({
      namespace: "@local",
      url: "http://localhost:8080/r/{name}.json",
    })
  })

  it("should throw for namespace without @", () => {
    expect(() => parseRegistryArg("foo")).toThrow("must start with @")
    expect(() => parseRegistryArg("magicui")).toThrow("must start with @")
    expect(() =>
      parseRegistryArg("mycompany=https://example.com/r/{name}.json")
    ).toThrow("must start with @")
  })
})

Dependencies

Frequently Asked Questions

What does add-registries.test.ts do?
add-registries.test.ts is a source file in the ui codebase, written in typescript. It belongs to the FrameworkTooling domain.
What does add-registries.test.ts depend on?
add-registries.test.ts imports 3 module(s): add.ts, parseRegistryArg, vitest.
Where is add-registries.test.ts in the architecture?
add-registries.test.ts is located at packages/shadcn/test/utils/add-registries.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