Home / File/ env.test.ts — ui Source File

env.test.ts — ui Source File

Architecture documentation for env.test.ts, a typescript file in the ui codebase. 4 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  b22db906_c5b1_9d62_cf27_a2755c5ff441["env.test.ts"]
  10d23973_b83e_4ea0_acf5_a6fed825e057["env.ts"]
  b22db906_c5b1_9d62_cf27_a2755c5ff441 --> 10d23973_b83e_4ea0_acf5_a6fed825e057
  7e579bd9_2bc3_4600_8351_8416c9a74be2["expandEnvVars"]
  b22db906_c5b1_9d62_cf27_a2755c5ff441 --> 7e579bd9_2bc3_4600_8351_8416c9a74be2
  6d237c9a_0eae_4072_d592_25014e6bed50["extractEnvVars"]
  b22db906_c5b1_9d62_cf27_a2755c5ff441 --> 6d237c9a_0eae_4072_d592_25014e6bed50
  c8d55bee_7008_1e1f_317b_8dc47b31b6a8["vitest"]
  b22db906_c5b1_9d62_cf27_a2755c5ff441 --> c8d55bee_7008_1e1f_317b_8dc47b31b6a8
  style b22db906_c5b1_9d62_cf27_a2755c5ff441 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/* eslint-disable turbo/no-undeclared-env-vars */
import { afterEach, beforeEach, describe, expect, it } from "vitest"

import { expandEnvVars, extractEnvVars } from "./env"

describe("expandEnvVars", () => {
  beforeEach(() => {
    process.env.TEST_TOKEN = "abc123"
    process.env.API_KEY = "secret"
  })

  afterEach(() => {
    delete process.env.TEST_TOKEN
    delete process.env.API_KEY
  })

  it("should expand environment variables", () => {
    expect(expandEnvVars("Bearer ${TEST_TOKEN}")).toBe("Bearer abc123")
    expect(expandEnvVars("key=${API_KEY}&token=${TEST_TOKEN}")).toBe(
      "key=secret&token=abc123"
    )
  })

  it("should replace missing env vars with empty string", () => {
    expect(expandEnvVars("Bearer ${MISSING_VAR}")).toBe("Bearer ")
    expect(expandEnvVars("${VAR1}:${VAR2}")).toBe(":")
  })

  it("should handle strings without env vars", () => {
    expect(expandEnvVars("no variables here")).toBe("no variables here")
    expect(expandEnvVars("https://example.com")).toBe("https://example.com")
  })
})

describe("extractEnvVars", () => {
  it("should extract environment variable names", () => {
    expect(extractEnvVars("Bearer ${TOKEN}")).toEqual(["TOKEN"])
    expect(extractEnvVars("${VAR1} and ${VAR2}")).toEqual(["VAR1", "VAR2"])
    expect(extractEnvVars("${SAME} and ${SAME}")).toEqual(["SAME", "SAME"])
  })

  it("should return empty array for no variables", () => {
    expect(extractEnvVars("no variables")).toEqual([])
    expect(extractEnvVars("")).toEqual([])
  })
})

Frequently Asked Questions

What does env.test.ts do?
env.test.ts is a source file in the ui codebase, written in typescript. It belongs to the FrameworkTooling domain.
What does env.test.ts depend on?
env.test.ts imports 4 module(s): env.ts, expandEnvVars, extractEnvVars, vitest.
Where is env.test.ts in the architecture?
env.test.ts is located at packages/shadcn/src/registry/env.test.ts (domain: FrameworkTooling, directory: packages/shadcn/src/registry).

Analyze Your Own Codebase

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

Try Supermodel Free