Get the name of a number, even if it's stupidly big.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

50 line
1.2 KiB

  1. import ones from './ones'
  2. it('should exist', () => {
  3. expect(ones).toBeDefined()
  4. })
  5. it('should be a callable', () => {
  6. expect(typeof ones).toBe('function')
  7. })
  8. it('should accept a minimum of 1 argument', () => {
  9. expect(ones).toHaveLength(1)
  10. })
  11. describe('on ordinary units', () => {
  12. test.each`
  13. value | display | name
  14. ${0} | ${'0'} | ${''}
  15. ${1} | ${'1'} | ${'un'}
  16. ${2} | ${'2'} | ${'duo'}
  17. ${3} | ${'3'} | ${'tre'}
  18. ${4} | ${'4'} | ${'quattuor'}
  19. ${5} | ${'5'} | ${'quin'}
  20. ${6} | ${'6'} | ${'sex'}
  21. ${7} | ${'7'} | ${'septen'}
  22. ${8} | ${'8'} | ${'octo'}
  23. ${9} | ${'9'} | ${'novem'}
  24. `('should return "$name" on $display', ({ value, name }) => {
  25. expect(ones(value, false)).toBe(name)
  26. })
  27. })
  28. describe('on special units', () => {
  29. test.each`
  30. value | display | name
  31. ${0} | ${'0'} | ${''}
  32. ${1} | ${'1'} | ${'m'}
  33. ${2} | ${'2'} | ${'b'}
  34. ${3} | ${'3'} | ${'tr'}
  35. ${4} | ${'4'} | ${'quadr'}
  36. ${5} | ${'5'} | ${'quin'}
  37. ${6} | ${'6'} | ${'sex'}
  38. ${7} | ${'7'} | ${'sept'}
  39. ${8} | ${'8'} | ${'oct'}
  40. ${9} | ${'9'} | ${'non'}
  41. `('should return "$name" on $display', ({ value, name }) => {
  42. expect(ones(value, true)).toBe(name)
  43. })
  44. })