Last active
March 8, 2019 01:40
-
-
Save MeetMartin/a1666b7c8f31b279af48ec70acbdaf4a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import { assert } from 'chai'; | |
import * as TextTransformation from '../src/text-transform-functional'; | |
describe('test atomic functions', () => { | |
it('trim(text) trims spaces', | |
() => assert.strictEqual(TextTransformation.trim(' Text '), 'Text')); | |
it('trim(text) trims tabs', | |
() => assert.strictEqual(TextTransformation.trim(' Text '), 'Text')); | |
it('trim(text) trims new lines', | |
() => assert.strictEqual(TextTransformation.trim("\nText\n"), 'Text')); | |
it('toLowerCase(text) turns text to lower case', | |
() => assert.strictEqual(TextTransformation.toLowerCase("pReSiDeNt"), 'president')); | |
it('capitalize(text) turns first character to Capital', | |
() => assert.strictEqual(TextTransformation.capitalize("pReSiDeNt"), 'PReSiDeNt')); | |
it('addExclamationMark(text) adds !', | |
() => assert.strictEqual(TextTransformation.addExclamationMark("text"), 'text!')); | |
it('addPunctuation(text) adds .', | |
() => assert.strictEqual(TextTransformation.addPunctuation("text"), 'text.')); | |
}); | |
describe('test composed functions', () => { | |
it('makeImportant(text) makes it capitalized, trimmed with ! at the end.', | |
() => assert.strictEqual(TextTransformation.makeImportant(' pReSiDeNt '), 'President!')); | |
it('makeUnimportant(text) makes it lowercase, trimmed with . at the end.', | |
() => assert.strictEqual(TextTransformation.makeUnimportant(' pReSiDeNt '), 'president.')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment