|
- import getNumberName from '../../../index';
-
- describe('Technical numbers', () => {
- describe('Number.MAX_SAFE_INTEGER', () => {
- it(
- 'converts Number.MAX_SAFE_INTEGER to nine quadrillion seven trillion one hundred ninety nine billion two hundred fifty four million seven hundred forty thousand nine hundred ninety one',
- () => {
- expect(Number.MAX_SAFE_INTEGER).toBe(9_007_199_254_740_991);
- expect(getNumberName(Number.MAX_SAFE_INTEGER))
- .toBe(
- 'nine quadrillion seven trillion one hundred ninety nine billion two hundred fifty four million seven hundred forty thousand nine hundred ninety one');
- },
- );
- });
-
- describe('Powers of 2', () => {
- it.each`
- value | name
- ${2 ** 0} | ${'one'}
- ${2 ** 1} | ${'two'}
- ${2 ** 2} | ${'four'}
- ${2 ** 3} | ${'eight'}
- ${2 ** 4} | ${'sixteen'}
- ${2 ** 5} | ${'thirty two'}
- ${2 ** 6} | ${'sixty four'}
- ${2 ** 7} | ${'one hundred twenty eight'}
- ${2 ** 8} | ${'two hundred fifty six'}
- ${2 ** 9} | ${'five hundred twelve'}
- ${2 ** 10} | ${'one thousand twenty four'}
- ${2 ** 11} | ${'two thousand forty eight'}
- ${2 ** 12} | ${'four thousand ninety six'}
- ${2 ** 13} | ${'eight thousand one hundred ninety two'}
- ${2 ** 14} | ${'sixteen thousand three hundred eighty four'}
- ${2 ** 15} | ${'thirty two thousand seven hundred sixty eight'}
- ${2 ** 16} | ${'sixty five thousand five hundred thirty six'}
- ${2 ** 17} | ${'one hundred thirty one thousand seventy two'}
- ${2 ** 18} | ${'two hundred sixty two thousand one hundred forty four'}
- ${2 ** 19} | ${'five hundred twenty four thousand two hundred eighty eight'}
- ${2 ** 20} | ${'one million forty eight thousand five hundred seventy six'}
- `('converts $value to $name', ({value, name}) => {
- expect(getNumberName(value)).toBe(name);
- });
- });
- });
|