mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-23 20:54:50 +03:00
Merge pull request #5254 from gitbutlerapp/add-tests-to-ui-slugify
UI: add tests to slugify
This commit is contained in:
commit
d78c77cf3d
30
apps/desktop/src/lib/utils/string.test.ts
Normal file
30
apps/desktop/src/lib/utils/string.test.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { slugify } from '$lib/utils/string';
|
||||
import { describe, expect, test } from 'vitest';
|
||||
|
||||
describe.concurrent('branch slugify with valid characters', () => {
|
||||
test('forward slashes are fine', () => {
|
||||
expect(slugify('my/branch')).toEqual('my/branch');
|
||||
});
|
||||
|
||||
test('capitalization is fine', () => {
|
||||
expect(slugify('MY/branch')).toEqual('MY/branch');
|
||||
});
|
||||
|
||||
test('numbers are fine', () => {
|
||||
expect(slugify('my/branch1')).toEqual('my/branch1');
|
||||
});
|
||||
});
|
||||
|
||||
describe.concurrent('branch slugify with replaced characters', () => {
|
||||
test('whitespaces are truncated', () => {
|
||||
expect(slugify(' my/branch ')).toEqual('my/branch');
|
||||
});
|
||||
|
||||
test('whitespace in the middle becomes dash', () => {
|
||||
expect(slugify('my branch')).toEqual('my-branch');
|
||||
});
|
||||
|
||||
test('most special characters are nuked', () => {
|
||||
expect(slugify('a!b@c$d;e%f^g&h*i(j)k+l=m~n`')).toEqual('abcdefghijklmn');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user