Home / File/ walk.test.ts — tailwindcss Source File

walk.test.ts — tailwindcss Source File

Architecture documentation for walk.test.ts, a typescript file in the tailwindcss codebase. 8 imports, 0 dependents.

File typescript Oxide 8 imports

Entity Profile

Dependency Diagram

graph LR
  6a6411a3_3999_5dc9_0674_3dd5b2e1342e["walk.test.ts"]
  b9cbffa4_c352_cf3c_268f_cbb174fb3a47["ast.ts"]
  6a6411a3_3999_5dc9_0674_3dd5b2e1342e --> b9cbffa4_c352_cf3c_268f_cbb174fb3a47
  1369a6dc_e395_347d_5d24_b88e22c5446d["decl"]
  6a6411a3_3999_5dc9_0674_3dd5b2e1342e --> 1369a6dc_e395_347d_5d24_b88e22c5446d
  085cf56e_8188_afb1_04da_5ccd0fb7babc["rule"]
  6a6411a3_3999_5dc9_0674_3dd5b2e1342e --> 085cf56e_8188_afb1_04da_5ccd0fb7babc
  9b49f3c6_0c8d_5c62_965c_30a1db6499f8["toCss"]
  6a6411a3_3999_5dc9_0674_3dd5b2e1342e --> 9b49f3c6_0c8d_5c62_965c_30a1db6499f8
  1b8f1c54_b1e9_e18d_0719_b7ad92808185["walk.ts"]
  6a6411a3_3999_5dc9_0674_3dd5b2e1342e --> 1b8f1c54_b1e9_e18d_0719_b7ad92808185
  4982d9ce_98d4_85d9_44af_7cc47b93c482["walk"]
  6a6411a3_3999_5dc9_0674_3dd5b2e1342e --> 4982d9ce_98d4_85d9_44af_7cc47b93c482
  47187d1b_a6f7_f734_0752_446b87b5cd9e["WalkAction"]
  6a6411a3_3999_5dc9_0674_3dd5b2e1342e --> 47187d1b_a6f7_f734_0752_446b87b5cd9e
  f1e05e5f_c1b2_a3f5_b2e8_3317b9243ac3["vitest"]
  6a6411a3_3999_5dc9_0674_3dd5b2e1342e --> f1e05e5f_c1b2_a3f5_b2e8_3317b9243ac3
  style 6a6411a3_3999_5dc9_0674_3dd5b2e1342e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { describe, expect, test } from 'vitest'
import { decl, rule, toCss, type AstNode as CSSAstNode } from './ast'
import { walk, WalkAction } from './walk'

type AstNode = { kind: string } | { kind: string; nodes: AstNode[] }

describe('AST Enter (function)', () => {
  test('visit all nodes in an AST', () => {
    let ast: AstNode[] = [
      {
        kind: 'a',
        nodes: [
          { kind: 'b', nodes: [{ kind: 'c' }] },
          { kind: 'd', nodes: [{ kind: 'e', nodes: [{ kind: 'f' }] }] },
          { kind: 'g', nodes: [{ kind: 'h' }] },
        ],
      },
      { kind: 'i' },
    ]

    let visited: string[] = []
    walk(ast, (node) => {
      visited.push(node.kind)
    })

    expect(visited).toEqual(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'])
  })

  test('visit all nodes in an AST and calculate their path', () => {
    let ast: AstNode[] = [
      {
        kind: 'a',
        nodes: [
          { kind: 'b', nodes: [{ kind: 'c' }] },
          { kind: 'd', nodes: [{ kind: 'e', nodes: [{ kind: 'f' }] }] },
          { kind: 'g', nodes: [{ kind: 'h' }] },
        ],
      },
      { kind: 'i' },
    ]

    let paths: string[] = []
    walk(ast, (node, ctx) => {
      let path = ctx.path().map((n) => n.kind)
      if (path.length === 0) path.unshift('ø')
      path.push(node.kind)

      paths.push(path.join(' → ') || 'ø')
    })

    expect(`\n${paths.join('\n')}\n`).toMatchInlineSnapshot(`
      "
      ø → a
      a → b
      a → b → c
      a → d
      a → d → e
      a → d → e → f
      a → g
      a → g → h
// ... (1537 more lines)

Domain

Types

Frequently Asked Questions

What does walk.test.ts do?
walk.test.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the Oxide domain.
What does walk.test.ts depend on?
walk.test.ts imports 8 module(s): WalkAction, ast.ts, decl, rule, toCss, vitest, walk, walk.ts.
Where is walk.test.ts in the architecture?
walk.test.ts is located at packages/tailwindcss/src/walk.test.ts (domain: Oxide, directory: packages/tailwindcss/src).

Analyze Your Own Codebase

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

Try Supermodel Free