destroy.js 933 B

12345678910111213141516171819202122232425
  1. QUnit.test( 'destroy', function( assert ) {
  2. 'use strict';
  3. var elem = document.querySelector('#destroy');
  4. var flkty = new Flickity( elem );
  5. var done = assert.async();
  6. // do it async
  7. setTimeout( function() {
  8. flkty.destroy();
  9. assert.strictEqual( elem.flickityGUID, undefined, 'flickityGUID removed' );
  10. assert.ok( !flkty.isActive, 'not active' );
  11. assert.ok( !Flickity.data( elem ), '.data() returns falsey' );
  12. assert.ok( elem.children[0], '.cell', 'cell is back as first child' );
  13. assert.ok( !matchesSelector( elem, '.flickity-enabled'), 'flickity-enabled class removed' );
  14. assert.ok( !elem.querySelector('.flickity-prev-next-button'), 'no buttons' );
  15. assert.ok( !elem.querySelector('.flickity-page-dots'), 'no page dots' );
  16. assert.ok( !elem.style.height, 'no height set' );
  17. assert.ok( !elem.children[0].style.left, 'first cell has no left position' );
  18. done();
  19. }, 20 );
  20. });