|
| 1 | +import { emojifyText, abbreviateNumber } from 'utils'; |
| 2 | +import emoji from 'node-emoji'; |
| 3 | + |
| 4 | +describe('Text Helper', () => { |
| 5 | + describe('emojifyText', () => { |
| 6 | + it('should call correcly with text params', () => { |
| 7 | + const emojify = jest.spyOn(emoji, 'emojify'); |
| 8 | + const input = 'I need more :coffee'; |
| 9 | + |
| 10 | + emojifyText(input); |
| 11 | + |
| 12 | + expect(emojify).toBeCalledWith(input); |
| 13 | + |
| 14 | + emojify.mockReset(); |
| 15 | + emojify.mockRestore(); |
| 16 | + }); |
| 17 | + }); |
| 18 | + |
| 19 | + describe('abbreviateNumber', () => { |
| 20 | + it('should return 1 when given 1', () => { |
| 21 | + const input = 1; |
| 22 | + const expected = 1; |
| 23 | + const result = abbreviateNumber(input); |
| 24 | + |
| 25 | + expect(result).toEqual(expected); |
| 26 | + }); |
| 27 | + |
| 28 | + it('should return 1k when given 1000', () => { |
| 29 | + const input = 1000; |
| 30 | + const expected = '1k'; |
| 31 | + const result = abbreviateNumber(input); |
| 32 | + |
| 33 | + expect(result).toEqual(expected); |
| 34 | + }); |
| 35 | + |
| 36 | + it('should return 1.1k when given 1100', () => { |
| 37 | + const input = 1100; |
| 38 | + const expected = '1.1k'; |
| 39 | + const result = abbreviateNumber(input); |
| 40 | + |
| 41 | + expect(result).toEqual(expected); |
| 42 | + }); |
| 43 | + |
| 44 | + it('should return 96.2k when given 96234', () => { |
| 45 | + const input = 96234; |
| 46 | + const expected = '96.2k'; |
| 47 | + const result = abbreviateNumber(input); |
| 48 | + |
| 49 | + expect(result).toEqual(expected); |
| 50 | + }); |
| 51 | + }); |
| 52 | +}); |
0 commit comments