toArray.test.js 427 B

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