forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslugify.test.js
More file actions
24 lines (22 loc) · 818 Bytes
/
slugify.test.js
File metadata and controls
24 lines (22 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const { stringify } = require('jest-matcher-utils')
const { slugify } = require('../slugify')
describe('given a string', () => {
it('lowers all characters', () => {
expect(slugify('STRING')).toEqual('string')
})
it('replaces spaces with dashes', () => {
expect(slugify('a lot of spaces')).toEqual('a-lot-of-spaces')
})
it('changes special characters to ascii', () => {
expect(slugify('á é í ó ú Á É Í Ó Ú ç Ç ª º ¹ ² ½ ¼')).toEqual(
'a-e-i-o-u-a-e-i-o-u-c-c-a-o-1-2-1-2-1-4',
)
})
describe('if input value is not a string', () => {
;[123, {}, [], null, undefined, true].forEach((invalidInput) => {
it(`returns undefined when value is ${stringify(invalidInput)}`, () => {
expect(slugify(invalidInput)).toEqual(undefined)
})
})
})
})