-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* implemented cleansing function * Explains what NBS is * Format
- Loading branch information
1 parent
8096cef
commit 0afd370
Showing
3 changed files
with
72 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { clean } from '../util'; | ||
|
||
describe('Courses Populate Test Suite', () => { | ||
it('Primitives and strings w/o NBS unchanged', () => { | ||
expect(clean(5)).toBe(5); | ||
expect(clean(null)).toBe(null); | ||
expect(clean(undefined)).toBe(undefined); | ||
expect(clean('hello')).toBe('hello'); | ||
}); | ||
|
||
it('String with NBS cleaned', () => { | ||
expect(clean('\u00a0')).toBe(' '); | ||
expect(clean('\u00a0\u00a0')).toBe(' '); | ||
expect(clean('\u00a0a\u00a0')).toBe(' a '); | ||
}); | ||
|
||
it('Array with NBS cleaned', () => { | ||
expect(clean(['hi', '\u00a0', 'goodbye'])).toEqual(['hi', ' ', 'goodbye']); | ||
}); | ||
|
||
it('Object with NBS cleansed', () => { | ||
const dirty = { | ||
foo: '\u00a0', | ||
foos: ['hello', '\u00a0', '\u00a0', 'goodbye'], | ||
bar: { | ||
baz: '\u00a0', | ||
buzz: 'farewell', | ||
}, | ||
}; | ||
const cleansed = clean(dirty); | ||
expect(cleansed).toEqual({ | ||
foo: ' ', | ||
foos: ['hello', ' ', ' ', 'goodbye'], | ||
bar: { | ||
baz: ' ', | ||
buzz: 'farewell', | ||
}, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters