Gets the name of a number, even if it's stupidly big. Supersedes TheoryOfNekomata/number-name.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 

48 rindas
1.9 KiB

  1. import getNumberName from '../../../index';
  2. import getLocalizedNumberName from './index';
  3. describe('Landon\'s original test cases', () => {
  4. describe('Basic conversions', () => {
  5. it.each`
  6. value | traditionalBritishName
  7. ${1} | ${'one'}
  8. ${1000} | ${'one thousand'}
  9. ${1000000} | ${'one million'}
  10. ${1000000000} | ${'one thousand million'}
  11. ${1000000000000} | ${'one billion'}
  12. ${1000000000000000} | ${'one thousand billion'}
  13. ${1000000000000000000} | ${'one trillion'}
  14. `('converts $value to $traditionalBritishName', ({value, traditionalBritishName}) => {
  15. expect(getNumberName(value, {locale: getLocalizedNumberName})).toBe(traditionalBritishName);
  16. });
  17. });
  18. describe('Medium size numbers (<= 1e+63)', () => {
  19. describe('Table 1', () => {
  20. it.each`
  21. value | traditionalBritishName
  22. ${'1e+9'} | ${'thousand million'}
  23. ${'1e+12'} | ${'billion'}
  24. ${'1e+15'} | ${'thousand billion'}
  25. ${'1e+18'} | ${'trillion'}
  26. ${'1e+21'} | ${'thousand trillion'}
  27. ${'1e+24'} | ${'quadrillion'}
  28. ${'1e+27'} | ${'thousand quadrillion'}
  29. ${'1e+30'} | ${'quintillion'}
  30. ${'1e+33'} | ${'thousand quintillion'}
  31. ${'1e+36'} | ${'sextillion'}
  32. ${'1e+39'} | ${'thousand sextillion'}
  33. ${'1e+42'} | ${'septillion'}
  34. ${'1e+45'} | ${'thousand septillion'}
  35. ${'1e+48'} | ${'octillion'}
  36. ${'1e+51'} | ${'thousand octillion'}
  37. ${'1e+54'} | ${'nonillion'}
  38. ${'1e+57'} | ${'thousand nonillion'}
  39. ${'1e+60'} | ${'decillion'}
  40. ${'1e+63'} | ${'thousand decillion'}
  41. `('converts $value to $traditionalBritishName', ({value, traditionalBritishName}) => {
  42. expect(getNumberName(value, {locale: getLocalizedNumberName})).toBe(`one ${traditionalBritishName}`);
  43. });
  44. });
  45. });
  46. });