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

env-helpers.test.ts — ui Source File

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

Entity Profile

Dependency Diagram

graph LR
  6ff0b4fb_dc28_0e2d_2a10_3e2e1d0a3d6b["env-helpers.test.ts"]
  6ea7c0f6_8e34_1742_bb2f_90e611bb6eda["env-helpers.ts"]
  6ff0b4fb_dc28_0e2d_2a10_3e2e1d0a3d6b --> 6ea7c0f6_8e34_1742_bb2f_90e611bb6eda
  1c137b43_b752_25b4_2fda_4972ce467a1b["findExistingEnvFile"]
  6ff0b4fb_dc28_0e2d_2a10_3e2e1d0a3d6b --> 1c137b43_b752_25b4_2fda_4972ce467a1b
  7d02ce11_67d3_b526_0793_571de14db36b["getNewEnvKeys"]
  6ff0b4fb_dc28_0e2d_2a10_3e2e1d0a3d6b --> 7d02ce11_67d3_b526_0793_571de14db36b
  c2125c45_1326_cb8c_9e8b_778770637845["isEnvFile"]
  6ff0b4fb_dc28_0e2d_2a10_3e2e1d0a3d6b --> c2125c45_1326_cb8c_9e8b_778770637845
  b18653bf_101d_ca3f_a9c5_a3788a04e629["mergeEnvContent"]
  6ff0b4fb_dc28_0e2d_2a10_3e2e1d0a3d6b --> b18653bf_101d_ca3f_a9c5_a3788a04e629
  f6d1e24d_2a4b_80a5_233e_1b31060a0b05["parseEnvContent"]
  6ff0b4fb_dc28_0e2d_2a10_3e2e1d0a3d6b --> f6d1e24d_2a4b_80a5_233e_1b31060a0b05
  eac8f98f_e40a_7fe8_f505_372c83d20c7a["fs"]
  6ff0b4fb_dc28_0e2d_2a10_3e2e1d0a3d6b --> eac8f98f_e40a_7fe8_f505_372c83d20c7a
  c8d55bee_7008_1e1f_317b_8dc47b31b6a8["vitest"]
  6ff0b4fb_dc28_0e2d_2a10_3e2e1d0a3d6b --> c8d55bee_7008_1e1f_317b_8dc47b31b6a8
  style 6ff0b4fb_dc28_0e2d_2a10_3e2e1d0a3d6b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { existsSync } from "fs"
import { beforeEach, describe, expect, test, vi } from "vitest"

import {
  findExistingEnvFile,
  getNewEnvKeys,
  isEnvFile,
  mergeEnvContent,
  parseEnvContent,
} from "./env-helpers"

// Mock fs module
vi.mock("fs", () => ({
  existsSync: vi.fn(),
}))

describe("isEnvFile", () => {
  test("should identify .env files", () => {
    expect(isEnvFile("/path/to/.env")).toBe(true)
    expect(isEnvFile(".env")).toBe(true)
    expect(isEnvFile("/path/to/.env.local")).toBe(true)
    expect(isEnvFile(".env.local")).toBe(true)
    expect(isEnvFile(".env.example")).toBe(true)
    expect(isEnvFile(".env.development.local")).toBe(true)
    expect(isEnvFile(".env.production.local")).toBe(true)
    expect(isEnvFile(".env.test.local")).toBe(true)
  })

  test("should not identify non-.env files", () => {
    expect(isEnvFile("/path/to/file.txt")).toBe(false)
    expect(isEnvFile("environment.ts")).toBe(false)
    expect(isEnvFile("/path/to/.environment")).toBe(false)
    expect(isEnvFile("env.config")).toBe(false)
  })
})

describe("parseEnvContent", () => {
  test("should parse basic key-value pairs", () => {
    const content = `KEY1=value1
KEY2=value2`
    expect(parseEnvContent(content)).toEqual({
      KEY1: "value1",
      KEY2: "value2",
    })
  })

  test("should handle comments and empty lines", () => {
    const content = `# This is a comment
KEY1=value1

# Another comment
KEY2=value2
`
    expect(parseEnvContent(content)).toEqual({
      KEY1: "value1",
      KEY2: "value2",
    })
  })

  test("should handle quoted values", () => {
// ... (310 more lines)

Frequently Asked Questions

What does env-helpers.test.ts do?
env-helpers.test.ts is a source file in the ui codebase, written in typescript. It belongs to the FrameworkTooling domain.
What does env-helpers.test.ts depend on?
env-helpers.test.ts imports 8 module(s): env-helpers.ts, findExistingEnvFile, fs, getNewEnvKeys, isEnvFile, mergeEnvContent, parseEnvContent, vitest.
Where is env-helpers.test.ts in the architecture?
env-helpers.test.ts is located at packages/shadcn/src/utils/env-helpers.test.ts (domain: FrameworkTooling, directory: packages/shadcn/src/utils).

Analyze Your Own Codebase

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

Try Supermodel Free