empty.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. QUnit.test( 'empty', function( assert ) {
  2. 'use strict';
  3. var gallery = document.querySelector('#empty');
  4. var flkty = new Flickity( gallery );
  5. assert.ok( true, 'empty gallery ok' );
  6. assert.ok( flkty.prevButton.element.disabled, 'previous button disabled' );
  7. assert.ok( flkty.nextButton.element.disabled, 'next button disabled' );
  8. assert.equal( flkty.pageDots.dots.length, 0, '0 page dots');
  9. flkty.resize();
  10. assert.ok( true, 'resize with empty gallery ok');
  11. function makeCellElem() {
  12. var cellElem = document.createElement('div');
  13. cellElem.className = 'cell';
  14. return cellElem;
  15. }
  16. flkty.append( makeCellElem() );
  17. assert.equal( flkty.cells.length, 1, 'added cell to empty gallery' );
  18. assert.ok( flkty.prevButton.element.disabled, 'previous button disabled' );
  19. assert.ok( flkty.nextButton.element.disabled, 'next button disabled' );
  20. assert.equal( flkty.pageDots.dots.length, 1, '1 page dots');
  21. // destroy and re-init with higher initialIndex
  22. flkty.destroy();
  23. flkty = new Flickity( gallery, {
  24. initialIndex: 2
  25. });
  26. // #291
  27. assert.ok( true, 'initializing with initialIndex > cells doesnt throw error' );
  28. });