Skip to content

Commit e8a40dc

Browse files
committed
CCM-11438 Add kebab case unit tests
1 parent 5400ab6 commit e8a40dc

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { toKebabCase } from '@utils/kebab-case';
2+
3+
describe('toKebabCase', () => {
4+
it('returns empty string for empty input', () => {
5+
expect(toKebabCase('')).toBe('');
6+
});
7+
8+
it('returns empty string for only symbols', () => {
9+
expect(toKebabCase('!!!')).toBe('');
10+
});
11+
it('converts spaces to hyphens', () => {
12+
expect(toKebabCase('this is a test')).toBe('this-is-a-test');
13+
});
14+
15+
it('removes leading and trailing non-alphanumeric characters', () => {
16+
expect(toKebabCase(' Hello World! ')).toBe('hello-world');
17+
});
18+
19+
it('converts underscores and special characters to hyphens', () => {
20+
expect(toKebabCase('some_text_with@symbols')).toBe(
21+
'some-text-with-symbols'
22+
);
23+
});
24+
25+
it('collapses multiple separators into one hyphen', () => {
26+
expect(toKebabCase('one--two___three!!')).toBe('one-two-three');
27+
});
28+
29+
it('handles numeric characters correctly', () => {
30+
expect(toKebabCase('Version 2.0.1')).toBe('version-2-0-1');
31+
});
32+
33+
it('handles mixed case input', () => {
34+
expect(toKebabCase('MyMixedCASEInput')).toBe('mymixedcaseinput');
35+
});
36+
37+
it('preserves valid alphanumeric strings without change except lowercase', () => {
38+
expect(toKebabCase('Already-Kebab-Case123')).toBe('already-kebab-case123');
39+
});
40+
});

0 commit comments

Comments
 (0)