Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions __tests__/tests/utilities/text-helper.js
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';

Copy link
Copy Markdown
Member

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 :?

emojifyText(input);

expect(emojify.calledWith(input)).toEqual(true);
});
});

describe('abbreviateNumber', () => {
it('should get 1 when give 1', () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to: 'should return 1 when given 1'

const input = 1;
const expected = 1;
const result = abbreviateNumber(input);

expect(result).toEqual(expected);
});

it('should get 1k when give 1000', () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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', () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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', () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declare these with const.

});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also add a test for something huge and random like 96234, which should equal 96.2k I think.

});
});