forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanse-input.test.js
More file actions
26 lines (25 loc) · 810 Bytes
/
cleanse-input.test.js
File metadata and controls
26 lines (25 loc) · 810 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
25
26
import { cleanseInput } from '../index'
describe('given an input validate it', () => {
describe('string contains symbols', () => {
it('returns parsed string', () => {
const testString = '!@#$%^&*()_+-=|{}\\[]<>?,./`:;\'"'
expect(cleanseInput(testString)).toEqual(
'!@#$%^&*()_+-=|{}\[]<>?,./`:;ʼ"',
)
})
})
describe('input is not given a string', () => {
describe('input is undefined', () => {
it('returns an empty string', () => {
const testString = undefined
expect(cleanseInput(testString)).toEqual('')
})
})
describe('input is null', () => {
it('returns an empty string', () => {
const testString = null
expect(cleanseInput(testString)).toEqual('')
})
})
})
})