summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLuke Ward <hello@lward.co.uk>2019-07-03 08:20:57 +0000
committerPaul Slaughter <pslaughter@gitlab.com>2019-07-03 08:20:57 +0000
commit0d32d31864eff4443c538f2ead8af5bc133eec7d (patch)
treea594c376c58597b2eb4339068e00ad35422adf46 /spec
parent903227b040e8e89a03c074513d03b20010ac4e92 (diff)
downloadgitlab-ce-0d32d31864eff4443c538f2ead8af5bc133eec7d.tar.gz
Replace slugifyWithHyphens with improved slugify function
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/lib/utils/text_utility_spec.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/spec/frontend/lib/utils/text_utility_spec.js b/spec/frontend/lib/utils/text_utility_spec.js
index 9e920d59093..dc886d0db3b 100644
--- a/spec/frontend/lib/utils/text_utility_spec.js
+++ b/spec/frontend/lib/utils/text_utility_spec.js
@@ -55,9 +55,24 @@ describe('text_utility', () => {
});
});
- describe('slugifyWithHyphens', () => {
+ 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.slugifyWithHyphens('My Input String')).toEqual('my-input-string');
+ 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('');
});
});