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

segment.test.ts — tailwindcss Source File

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

File typescript Oxide 3 imports

Entity Profile

Dependency Diagram

graph LR
  843cab03_3a6d_1b2a_da72_197863df41ad["segment.test.ts"]
  bb9924cc_8308_a1f9_0e30_76de45a64970["segment.ts"]
  843cab03_3a6d_1b2a_da72_197863df41ad --> bb9924cc_8308_a1f9_0e30_76de45a64970
  c58cbb33_f3cc_0b4f_844a_15bf66a1dc61["segment"]
  843cab03_3a6d_1b2a_da72_197863df41ad --> c58cbb33_f3cc_0b4f_844a_15bf66a1dc61
  f1e05e5f_c1b2_a3f5_b2e8_3317b9243ac3["vitest"]
  843cab03_3a6d_1b2a_da72_197863df41ad --> f1e05e5f_c1b2_a3f5_b2e8_3317b9243ac3
  style 843cab03_3a6d_1b2a_da72_197863df41ad fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { expect, it } from 'vitest'
import { segment } from './segment'

it('should result in a single segment when the separator is not present', () => {
  expect(segment('foo', ':')).toEqual(['foo'])
})

it('should split by the separator', () => {
  expect(segment('foo:bar:baz', ':')).toEqual(['foo', 'bar', 'baz'])
})

it('should not split inside of parens', () => {
  expect(segment('a:(b:c):d', ':')).toEqual(['a', '(b:c)', 'd'])
})

it('should not split inside of brackets', () => {
  expect(segment('a:[b:c]:d', ':')).toEqual(['a', '[b:c]', 'd'])
})

it('should not split inside of curlies', () => {
  expect(segment('a:{b:c}:d', ':')).toEqual(['a', '{b:c}', 'd'])
})

it('should not split inside of double quotes', () => {
  expect(segment('a:"b:c":d', ':')).toEqual(['a', '"b:c"', 'd'])
})

it('should not split inside of single quotes', () => {
  expect(segment("a:'b:c':d", ':')).toEqual(['a', "'b:c'", 'd'])
})

it('should not crash when double quotes are unbalanced', () => {
  expect(segment('a:"b:c:d', ':')).toEqual(['a', '"b:c:d'])
})

it('should not crash when single quotes are unbalanced', () => {
  expect(segment("a:'b:c:d", ':')).toEqual(['a', "'b:c:d"])
})

it('should skip escaped double quotes', () => {
  expect(segment(String.raw`a:"b:c\":d":e`, ':')).toEqual(['a', String.raw`"b:c\":d"`, 'e'])
})

it('should skip escaped single quotes', () => {
  expect(segment(String.raw`a:'b:c\':d':e`, ':')).toEqual(['a', String.raw`'b:c\':d'`, 'e'])
})

it('should split by the escape sequence which is escape as well', () => {
  expect(segment('a\\b\\c\\d', '\\')).toEqual(['a', 'b', 'c', 'd'])
  expect(segment('a\\(b\\c)\\d', '\\')).toEqual(['a', '(b\\c)', 'd'])
  expect(segment('a\\[b\\c]\\d', '\\')).toEqual(['a', '[b\\c]', 'd'])
  expect(segment('a\\{b\\c}\\d', '\\')).toEqual(['a', '{b\\c}', 'd'])
})

Domain

Dependencies

Frequently Asked Questions

What does segment.test.ts do?
segment.test.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the Oxide domain.
What does segment.test.ts depend on?
segment.test.ts imports 3 module(s): segment, segment.ts, vitest.
Where is segment.test.ts in the architecture?
segment.test.ts is located at packages/tailwindcss/src/utils/segment.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