Home / File/ brace-expansion.test.ts — tailwindcss Source File

brace-expansion.test.ts — tailwindcss Source File

Architecture documentation for brace-expansion.test.ts, a typescript file in the tailwindcss codebase. 3 imports, 0 dependents.

File typescript Oxide 3 imports

Entity Profile

Dependency Diagram

graph LR
  d4b93066_2541_11a9_46a9_f54c21bf0b95["brace-expansion.test.ts"]
  dc817c0a_ee3b_7666_cb9d_ef0ab5b72986["brace-expansion.ts"]
  d4b93066_2541_11a9_46a9_f54c21bf0b95 --> dc817c0a_ee3b_7666_cb9d_ef0ab5b72986
  91a1286b_b296_e99a_4150_7ded5cd2aa4e["expand"]
  d4b93066_2541_11a9_46a9_f54c21bf0b95 --> 91a1286b_b296_e99a_4150_7ded5cd2aa4e
  f1e05e5f_c1b2_a3f5_b2e8_3317b9243ac3["vitest"]
  d4b93066_2541_11a9_46a9_f54c21bf0b95 --> f1e05e5f_c1b2_a3f5_b2e8_3317b9243ac3
  style d4b93066_2541_11a9_46a9_f54c21bf0b95 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { describe, expect, test } from 'vitest'
import { expand } from './brace-expansion'

describe('expand(…)', () => {
  test.each([
    ['a/b/c', ['a/b/c']],

    // Groups
    ['a/{x,y,z}/b', ['a/x/b', 'a/y/b', 'a/z/b']],
    ['{a,b}/{x,y}', ['a/x', 'a/y', 'b/x', 'b/y']],
    ['{{xs,sm,md,lg}:,}hidden', ['xs:hidden', 'sm:hidden', 'md:hidden', 'lg:hidden', 'hidden']],

    // Numeric ranges
    ['a/{0..5}/b', ['a/0/b', 'a/1/b', 'a/2/b', 'a/3/b', 'a/4/b', 'a/5/b']],
    ['a/{-5..0}/b', ['a/-5/b', 'a/-4/b', 'a/-3/b', 'a/-2/b', 'a/-1/b', 'a/0/b']],
    ['a/{0..-5}/b', ['a/0/b', 'a/-1/b', 'a/-2/b', 'a/-3/b', 'a/-4/b', 'a/-5/b']],
    ['a/{0..10..5}/b', ['a/0/b', 'a/5/b', 'a/10/b']],
    ['a/{0..10..-5}/b', ['a/10/b', 'a/5/b', 'a/0/b']],
    ['a/{10..0..5}/b', ['a/10/b', 'a/5/b', 'a/0/b']],
    ['a/{10..0..-5}/b', ['a/0/b', 'a/5/b', 'a/10/b']],

    // Numeric range with padding (we do not support padding)
    ['a/{00..05}/b', ['a/0/b', 'a/1/b', 'a/2/b', 'a/3/b', 'a/4/b', 'a/5/b']],
    ['a{001..9}b', ['a1b', 'a2b', 'a3b', 'a4b', 'a5b', 'a6b', 'a7b', 'a8b', 'a9b']],

    // Numeric range with step
    ['a/{0..5..2}/b', ['a/0/b', 'a/2/b', 'a/4/b']],
    [
      'bg-red-{100..900..100}',
      [
        'bg-red-100',
        'bg-red-200',
        'bg-red-300',
        'bg-red-400',
        'bg-red-500',
        'bg-red-600',
        'bg-red-700',
        'bg-red-800',
        'bg-red-900',
      ],
    ],

    // Nested braces
    ['a{b,c,/{x,y}}/e', ['ab/e', 'ac/e', 'a/x/e', 'a/y/e']],
    ['a{b,c,/{x,y},{z,w}}/e', ['ab/e', 'ac/e', 'a/x/e', 'a/y/e', 'az/e', 'aw/e']],
    ['a{b,c,/{x,y},{0..2}}/e', ['ab/e', 'ac/e', 'a/x/e', 'a/y/e', 'a0/e', 'a1/e', 'a2/e']],
    [
      'bg-red-{50,{100..900..100},950}',
      [
        'bg-red-50',
        'bg-red-100',
        'bg-red-200',
        'bg-red-300',
        'bg-red-400',
        'bg-red-500',
        'bg-red-600',
        'bg-red-700',
        'bg-red-800',
        'bg-red-900',
        'bg-red-950',
      ],
    ],

    // Should not try to expand ranges with decimals
    ['{1.1..2.2}', ['1.1..2.2']],
  ])('should expand %s (%#)', (input, expected) => {
    expect(expand(input).sort()).toEqual(expected.sort())
  })

  test('throws on unbalanced braces', () => {
    expect(() => expand('a{b,c{d,e},{f,g}h}x{y,z')).toThrowErrorMatchingInlineSnapshot(
      `[Error: The pattern \`x{y,z\` is not balanced.]`,
    )
  })

  test('throws when step is set to zero', () => {
    expect(() => expand('a{0..5..0}/b')).toThrowErrorMatchingInlineSnapshot(
      `[Error: Step cannot be zero in sequence expansion.]`,
    )
  })
})

Domain

Dependencies

Frequently Asked Questions

What does brace-expansion.test.ts do?
brace-expansion.test.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the Oxide domain.
What does brace-expansion.test.ts depend on?
brace-expansion.test.ts imports 3 module(s): brace-expansion.ts, expand, vitest.
Where is brace-expansion.test.ts in the architecture?
brace-expansion.test.ts is located at packages/tailwindcss/src/utils/brace-expansion.test.ts (domain: Oxide, directory: packages/tailwindcss/src/utils).

Analyze Your Own Codebase

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

Try Supermodel Free