forked from tailwindlabs/tailwindcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsegment.test.ts
More file actions
29 lines (23 loc) · 1.01 KB
/
segment.test.ts
File metadata and controls
29 lines (23 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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 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'])
})