formatAbbreviatedNumber.spec.jsx 960 B

123456789101112131415161718192021
  1. import formatAbbreviatedNumber from 'app/utils/formatAbbreviatedNumber';
  2. describe('formatAbbreviatedNumber()', function() {
  3. it('should abbreviate numbers', function() {
  4. expect(formatAbbreviatedNumber(0)).toBe('0');
  5. expect(formatAbbreviatedNumber(100)).toBe('100');
  6. expect(formatAbbreviatedNumber(1000)).toBe('1k');
  7. expect(formatAbbreviatedNumber(10000000)).toBe('10m');
  8. expect(formatAbbreviatedNumber(100000000000)).toBe('100b');
  9. expect(formatAbbreviatedNumber(1000000000000)).toBe('1000b');
  10. });
  11. it('should abbreviate numbers that are strings', function() {
  12. expect(formatAbbreviatedNumber('00')).toBe('0');
  13. expect(formatAbbreviatedNumber('100')).toBe('100');
  14. expect(formatAbbreviatedNumber('1000')).toBe('1k');
  15. expect(formatAbbreviatedNumber('10000000')).toBe('10m');
  16. expect(formatAbbreviatedNumber('100000000000')).toBe('100b');
  17. expect(formatAbbreviatedNumber('1000000000000')).toBe('1000b');
  18. });
  19. });