decode-arbitrary-value.test.ts — tailwindcss Source File
Architecture documentation for decode-arbitrary-value.test.ts, a typescript file in the tailwindcss codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 255bd22e_9af3_f897_fdcf_33b0fca12156["decode-arbitrary-value.test.ts"] e90d9c51_31f0_3175_a861_610a15e277e5["decode-arbitrary-value.ts"] 255bd22e_9af3_f897_fdcf_33b0fca12156 --> e90d9c51_31f0_3175_a861_610a15e277e5 2e1adb5d_9a16_16d9_9e0d_e7ef80a3ec69["decodeArbitraryValue"] 255bd22e_9af3_f897_fdcf_33b0fca12156 --> 2e1adb5d_9a16_16d9_9e0d_e7ef80a3ec69 696bd648_5f24_1b59_8e8b_7a97a692869e["vitest"] 255bd22e_9af3_f897_fdcf_33b0fca12156 --> 696bd648_5f24_1b59_8e8b_7a97a692869e style 255bd22e_9af3_f897_fdcf_33b0fca12156 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { describe, expect, it } from 'vitest'
import { decodeArbitraryValue } from './decode-arbitrary-value'
describe('decoding arbitrary values', () => {
it('should replace an underscore with a space', () => {
expect(decodeArbitraryValue('foo_bar')).toBe('foo bar')
})
it('should replace multiple underscores with spaces', () => {
expect(decodeArbitraryValue('__foo__bar__')).toBe(' foo bar ')
})
it('should replace escaped underscores with a normal underscore', () => {
expect(decodeArbitraryValue('foo\\_bar')).toBe('foo_bar')
})
it('should not replace underscores in url()', () => {
expect(decodeArbitraryValue('url(./my_file.jpg)')).toBe('url(./my_file.jpg)')
expect(decodeArbitraryValue('no-repeat_url(./my_file.jpg)')).toBe(
'no-repeat url(./my_file.jpg)',
)
})
it('should not replace underscores in the first argument of var()', () => {
expect(decodeArbitraryValue('var(--spacing-1_5)')).toBe('var(--spacing-1_5)')
expect(decodeArbitraryValue('var(--spacing-1_5,_1rem)')).toBe('var(--spacing-1_5, 1rem)')
expect(decodeArbitraryValue('var(--spacing-1_5,_var(--spacing-2_5,_1rem))')).toBe(
'var(--spacing-1_5, var(--spacing-2_5, 1rem))',
)
})
it('should not replace underscores in the first argument of theme()', () => {
expect(decodeArbitraryValue('theme(--spacing-1_5)')).toBe('theme(--spacing-1_5)')
expect(decodeArbitraryValue('theme(--spacing-1_5,_1rem)')).toBe('theme(--spacing-1_5, 1rem)')
expect(decodeArbitraryValue('theme(--spacing-1_5,_theme(--spacing-2_5,_1rem))')).toBe(
'theme(--spacing-1_5, theme(--spacing-2_5, 1rem))',
)
})
it('should leave var(…) as is', () => {
expect(decodeArbitraryValue('var(--foo)')).toBe('var(--foo)')
expect(decodeArbitraryValue('var(--headings-h1-size)')).toBe('var(--headings-h1-size)')
})
})
describe('adds spaces around math operators', () => {
let table = [
// math functions like calc(…) get spaces around operators
['calc(1+2)', 'calc(1 + 2)'],
['calc(100%+1rem)', 'calc(100% + 1rem)'],
['calc(1+calc(100%-20px))', 'calc(1 + calc(100% - 20px))'],
['calc(var(--headings-h1-size)*100)', 'calc(var(--headings-h1-size) * 100)'],
[
'calc(var(--headings-h1-size)*calc(100%+50%))',
'calc(var(--headings-h1-size) * calc(100% + 50%))',
],
['min(1+2)', 'min(1 + 2)'],
['max(1+2)', 'max(1 + 2)'],
['clamp(1+2,1+3,1+4)', 'clamp(1 + 2, 1 + 3, 1 + 4)'],
['var(--width, calc(100%+1rem))', 'var(--width, calc(100% + 1rem))'],
// ... (106 more lines)
Domain
Dependencies
Source
Frequently Asked Questions
What does decode-arbitrary-value.test.ts do?
decode-arbitrary-value.test.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the OxideEngine domain.
What does decode-arbitrary-value.test.ts depend on?
decode-arbitrary-value.test.ts imports 3 module(s): decode-arbitrary-value.ts, decodeArbitraryValue, vitest.
Where is decode-arbitrary-value.test.ts in the architecture?
decode-arbitrary-value.test.ts is located at packages/tailwindcss/src/utils/decode-arbitrary-value.test.ts (domain: OxideEngine, 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