Home / File/ transform-style-map.test.ts — ui Source File

transform-style-map.test.ts — ui Source File

Architecture documentation for transform-style-map.test.ts, a typescript file in the ui codebase. 5 imports, 0 dependents.

File typescript FrameworkTooling CLICore 5 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  b6929276_0c11_78e4_0d6e_5cbe870a5cec["transform-style-map.test.ts"]
  20ad6f91_6d0b_ef0e_6867_01a114c31d1d["create-style-map.ts"]
  b6929276_0c11_78e4_0d6e_5cbe870a5cec --> 20ad6f91_6d0b_ef0e_6867_01a114c31d1d
  cef4e429_7112_fef5_ae0b_a838a57ccf71["transform-style-map.ts"]
  b6929276_0c11_78e4_0d6e_5cbe870a5cec --> cef4e429_7112_fef5_ae0b_a838a57ccf71
  69e29c3a_597d_3ecf_b7be_50b09c93f556["transformStyleMap"]
  b6929276_0c11_78e4_0d6e_5cbe870a5cec --> 69e29c3a_597d_3ecf_b7be_50b09c93f556
  4f6f7e78_23ff_4f5f_c723_474454f64c85["ts-morph"]
  b6929276_0c11_78e4_0d6e_5cbe870a5cec --> 4f6f7e78_23ff_4f5f_c723_474454f64c85
  c8d55bee_7008_1e1f_317b_8dc47b31b6a8["vitest"]
  b6929276_0c11_78e4_0d6e_5cbe870a5cec --> c8d55bee_7008_1e1f_317b_8dc47b31b6a8
  style b6929276_0c11_78e4_0d6e_5cbe870a5cec fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { Project, ScriptKind } from "ts-morph"
import { describe, expect, it } from "vitest"

import { type StyleMap } from "./create-style-map"
import { transformStyleMap } from "./transform-style-map"

const baseStyleMap: StyleMap = {
  "cn-foo": "bg-background gap-4 rounded-xl",
}

async function applyTransform(source: string, styleMap: StyleMap) {
  const project = new Project({
    useInMemoryFileSystem: true,
  })

  const sourceFile = project.createSourceFile("component.tsx", source, {
    scriptKind: ScriptKind.TSX,
    overwrite: true,
  })

  await transformStyleMap({ sourceFile, styleMap })

  return sourceFile.getText()
}

describe("transformStyleMap", () => {
  it("adds tailwind classes to existing cn call", async () => {
    const source = `import * as React from "react"
import { cn } from "@/lib/utils"

function Foo({ className, ...props }: { className?: string }) {
  return (
    <div className={cn("cn-foo existing-class", className)} {...props} />
  )
}
`

    const result = await applyTransform(source, baseStyleMap)

    expect(result).toMatchInlineSnapshot(`
      "import * as React from "react"
      import { cn } from "@/lib/utils"

      function Foo({ className, ...props }: { className?: string }) {
        return (
          <div className={cn("bg-background gap-4 rounded-xl existing-class", className)} {...props} />
        )
      }
      "
    `)
  })

  it("adds tailwind classes to string literal className", async () => {
    const source = `import * as React from "react"

function Foo(props: React.ComponentProps<"div">) {
  return <div className="cn-foo" {...props} />
}
`

// ... (971 more lines)

Subdomains

Functions

Frequently Asked Questions

What does transform-style-map.test.ts do?
transform-style-map.test.ts is a source file in the ui codebase, written in typescript. It belongs to the FrameworkTooling domain, CLICore subdomain.
What functions are defined in transform-style-map.test.ts?
transform-style-map.test.ts defines 1 function(s): applyTransform.
What does transform-style-map.test.ts depend on?
transform-style-map.test.ts imports 5 module(s): create-style-map.ts, transform-style-map.ts, transformStyleMap, ts-morph, vitest.
Where is transform-style-map.test.ts in the architecture?
transform-style-map.test.ts is located at packages/shadcn/src/styles/transform-style-map.test.ts (domain: FrameworkTooling, subdomain: CLICore, directory: packages/shadcn/src/styles).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free