-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5254 from gitbutlerapp/add-tests-to-ui-slugify
UI: add tests to slugify
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
}); | ||
}); |