-
Notifications
You must be signed in to change notification settings - Fork 772
test(text-helper): add test for emojifyText, abbreviateNumber #568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
5f6376a
c54a9cc
0a4ef41
c7af126
90467ea
fd2b6a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { emojifyText, abbreviateNumber } from 'utils'; | ||
| import sinon from 'sinon'; | ||
| import emoji from 'node-emoji'; | ||
|
|
||
| describe('Text Helper', () => { | ||
| describe('emojifyText', () => { | ||
| it('should call correcly with text params', () => { | ||
| const emojify = sinon.spy(emoji, 'emojify'); | ||
| const input = 'I need more :coffee'; | ||
| emojifyText(input); | ||
|
|
||
| expect(emojify.calledWith(input)).toEqual(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe('abbreviateNumber', () => { | ||
| it('should get 1 when give 1', () => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change this to: |
||
| const input = 1; | ||
| const expected = 1; | ||
| const result = abbreviateNumber(input); | ||
|
|
||
| expect(result).toEqual(expected); | ||
| }); | ||
|
|
||
| it('should get 1k when give 1000', () => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apply same pattern as above |
||
| const input = 1000; | ||
| const expected = '1k'; | ||
| const result = abbreviateNumber(input); | ||
|
|
||
| expect(result).toEqual(expected); | ||
| }); | ||
|
|
||
| it('should get 1.1k when give 1100', () => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ^ |
||
| const input = 1100; | ||
| const expected = '1.1k'; | ||
| const result = abbreviateNumber(input); | ||
|
|
||
| expect(result).toEqual(expected); | ||
| }); | ||
|
|
||
| it('should get 96.2k when give 96234', () => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ^ |
||
| const input = 96234; | ||
| const expected = '96.2k'; | ||
| const result = abbreviateNumber(input); | ||
|
|
||
| expect(result).toEqual(expected); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Declare these with |
||
| }); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also add a test for something huge and random like |
||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there not at the end
:?