compare.test.ts — tailwindcss Source File
Architecture documentation for compare.test.ts, a typescript file in the tailwindcss codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR fd535f00_ad9f_3f14_e5f7_d9c0535e6178["compare.test.ts"] 2735e2c9_52ba_b31c_44c9_a72c4826e6b7["compare.ts"] fd535f00_ad9f_3f14_e5f7_d9c0535e6178 --> 2735e2c9_52ba_b31c_44c9_a72c4826e6b7 7787e2e6_2e19_8e07_7666_21a94194841f["compare"] fd535f00_ad9f_3f14_e5f7_d9c0535e6178 --> 7787e2e6_2e19_8e07_7666_21a94194841f 696bd648_5f24_1b59_8e8b_7a97a692869e["vitest"] fd535f00_ad9f_3f14_e5f7_d9c0535e6178 --> 696bd648_5f24_1b59_8e8b_7a97a692869e style fd535f00_ad9f_3f14_e5f7_d9c0535e6178 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { expect, it } from 'vitest'
import { compare } from './compare'
const LESS = -1
const EQUAL = 0
const GREATER = 1
it.each([
// Same strings
['abc', 'abc', EQUAL],
// Shorter string comes first
['abc', 'abcd', LESS],
// Longer string comes first
['abcd', 'abc', GREATER],
// Numbers
['1', '1', EQUAL],
['1', '2', LESS],
['2', '1', GREATER],
['1', '10', LESS],
['10', '1', GREATER],
// Numbers of different lengths
['75', '700', LESS],
['700', '75', GREATER],
['75', '770', LESS],
['770', '75', GREATER],
])('should compare "%s" with "%s" as "%d"', (a, b, expected) => {
expect(Math.sign(compare(a, b))).toBe(expected)
})
it('should sort strings with numbers consistently using the `compare` function', () => {
expect(
['p-0', 'p-0.5', 'p-1', 'p-1.5', 'p-10', 'p-12', 'p-2', 'p-20', 'p-21']
.sort(() => Math.random() - 0.5) // Shuffle the array
.sort(compare), // Sort the array
).toMatchInlineSnapshot(`
[
"p-0",
"p-0.5",
"p-1",
"p-1.5",
"p-2",
"p-10",
"p-12",
"p-20",
"p-21",
]
`)
})
it('should sort strings with modifiers consistently using the `compare` function', () => {
expect(
[
'text-5xl',
'text-6xl',
'text-6xl/loose',
'text-6xl/wide',
// ... (109 more lines)
Domain
Dependencies
- compare
- compare.ts
- vitest
Source
Frequently Asked Questions
What does compare.test.ts do?
compare.test.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the OxideEngine domain.
What does compare.test.ts depend on?
compare.test.ts imports 3 module(s): compare, compare.ts, vitest.
Where is compare.test.ts in the architecture?
compare.test.ts is located at packages/tailwindcss/src/utils/compare.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