make-array.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. QUnit.test( 'makeArray', function( assert ) {
  2. var makeArray = fizzyUIUtils.makeArray;
  3. var aryA = [ 0, 1, 2 ];
  4. var aryB = makeArray( aryA );
  5. assert.deepEqual( aryA, aryB, 'makeArray on array returns same array' );
  6. var itemElems = document.querySelectorAll('.grid-a .item');
  7. var items = makeArray( itemElems );
  8. assert.ok( Array.isArray( items ), 'makeArray on querySelectorAll NodeList' );
  9. assert.equal( items.length, itemElems.length, 'length matches' );
  10. var grids = makeArray( document.querySelector('.grid-a') );
  11. assert.ok( Array.isArray( grids ), 'makeArray on single element is array' );
  12. assert.equal( grids.length, 1, 'length = 1' );
  13. var empty = makeArray();
  14. assert.deepEqual( empty, [], 'makeArray on undefined is empty array' );
  15. assert.equal( empty.length, 0, 'length = 0' );
  16. assert.ok( empty[0] === undefined, '[0] is undefined' );
  17. // isotope#1235
  18. var aryC = makeArray('foo');
  19. assert.deepEqual( aryC, [ 'foo' ], 'string turns to single array item' );
  20. var nullAry = makeArray( null );
  21. assert.deepEqual( nullAry, [], 'makeArray(null) returns empty array' );
  22. var falseAry = makeArray( false );
  23. assert.deepEqual( falseAry, [ false ], 'makeArray(false) returns array with false' );
  24. assert.equal( falseAry.length, 1, 'falseyAry has 1 item' );
  25. });