diff options
Diffstat (limited to 'spec/frontend/lib/utils/text_utility_spec.js')
-rw-r--r-- | spec/frontend/lib/utils/text_utility_spec.js | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/spec/frontend/lib/utils/text_utility_spec.js b/spec/frontend/lib/utils/text_utility_spec.js index 8e31fc792c5..49a160c9f23 100644 --- a/spec/frontend/lib/utils/text_utility_spec.js +++ b/spec/frontend/lib/utils/text_utility_spec.js @@ -45,29 +45,18 @@ describe('text_utility', () => { }); describe('slugify', () => { - it('should remove accents and convert to lower case', () => { - expect(textUtils.slugify('João')).toEqual('jo-o'); - }); - it('should replaces whitespaces with hyphens and convert to lower case', () => { - expect(textUtils.slugify('My Input String')).toEqual('my-input-string'); - }); - it('should remove trailing whitespace and replace whitespaces within string with a hyphen', () => { - expect(textUtils.slugify(' a new project ')).toEqual('a-new-project'); - }); - it('should only remove non-allowed special characters', () => { - expect(textUtils.slugify('test!_pro-ject~')).toEqual('test-_pro-ject'); - }); - it('should squash multiple hypens', () => { - expect(textUtils.slugify('test!!!!_pro-ject~')).toEqual('test-_pro-ject'); - }); - it('should return empty string if only non-allowed characters', () => { - expect(textUtils.slugify('здрасти')).toEqual(''); - }); - it('should squash multiple separators', () => { - expect(textUtils.slugify('Test:-)')).toEqual('test'); - }); - it('should trim any separators from the beginning and end of the slug', () => { - expect(textUtils.slugify('-Test:-)-')).toEqual('test'); + it.each` + title | input | output + ${'should remove accents and convert to lower case'} | ${'João'} | ${'jo-o'} + ${'should replaces whitespaces with hyphens and convert to lower case'} | ${'My Input String'} | ${'my-input-string'} + ${'should remove trailing whitespace and replace whitespaces within string with a hyphen'} | ${' a new project '} | ${'a-new-project'} + ${'should only remove non-allowed special characters'} | ${'test!_pro-ject~'} | ${'test-_pro-ject'} + ${'should squash to multiple non-allowed special characters'} | ${'test!!!!_pro-ject~'} | ${'test-_pro-ject'} + ${'should return empty string if only non-allowed characters'} | ${'дружба'} | ${''} + ${'should squash multiple separators'} | ${'Test:-)'} | ${'test'} + ${'should trim any separators from the beginning and end of the slug'} | ${'-Test:-)-'} | ${'test'} + `('$title', ({ input, output }) => { + expect(textUtils.slugify(input)).toBe(output); }); }); |