toArray.test.js 384 B

12345678910111213141516171819202122
  1. const toArray = require('./toArray')
  2. describe('toArray', () => {
  3. it('should convert a array-like object into an array', () => {
  4. const obj = {
  5. '0': 'zero',
  6. '1': 'one',
  7. '2': 'two',
  8. '3': 'three',
  9. '4': 'four',
  10. length: 5
  11. }
  12. expect(toArray(obj)).toEqual([
  13. 'zero',
  14. 'one',
  15. 'two',
  16. 'three',
  17. 'four'
  18. ])
  19. })
  20. })