mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-23 07:42:10 +00:00
23 lines
900 B
TypeScript
23 lines
900 B
TypeScript
import Slug from '../../Utils/Slug';
|
|
describe('Slug.getSlug()', () => {
|
|
test('should return empty string, if name is empty ', () => {
|
|
expect(Slug.getSlug('')).toEqual('');
|
|
expect(Slug.getSlug(' ')).toEqual('');
|
|
});
|
|
test('should generate a slug from a valid name when name is null', () => {
|
|
expect(Slug.getSlug(null)).toMatch(/^[a-z0-9-]+$/);
|
|
});
|
|
test('should replaces spaces in nonEmpty with hyphen -', () => {
|
|
expect(Slug.getSlug('this is slug')).toMatch(/this-is-slug/g);
|
|
});
|
|
|
|
test('should append 10 numbers if non-empty string name is given', () => {
|
|
expect(Slug.getSlug('slug')).toMatch(/^slug-+[\d]{10}$/);
|
|
});
|
|
test('should remove character in [&*+~.,\\/()|\'"!:@]', () => {
|
|
expect(Slug.getSlug(' *+~.,\\/()\'"!:@slug is awesome')).toMatch(
|
|
/^slug-is-awesome-+[\d]{10}$/
|
|
);
|
|
});
|
|
});
|