prev-next-buttons.js 1.1 KB

123456789101112131415161718192021222324252627
  1. QUnit.test( 'prev-next-buttons', function( assert ) {
  2. 'use strict';
  3. var elem = document.querySelector('#prev-next-buttons');
  4. var flkty = new Flickity( elem );
  5. var prevElem = elem.querySelector('.flickity-prev-next-button.previous');
  6. var nextElem = elem.querySelector('.flickity-prev-next-button.next');
  7. assert.ok( prevElem, 'previous button in DOM' );
  8. assert.ok( nextElem, 'next button in DOM' );
  9. assert.equal( flkty.prevButton.element, prevElem, 'previous button element matches prevButton.element' );
  10. assert.equal( flkty.nextButton.element, nextElem, 'next button element matches nextButton.element' );
  11. assert.ok( prevElem.disabled, 'previous button is disabled at first index' );
  12. prevElem.focus();
  13. prevElem.click();
  14. assert.equal( flkty.selectedIndex, 0, 'selectedIndex still at 0' );
  15. nextElem.focus();
  16. nextElem.click();
  17. assert.equal( flkty.selectedIndex, 1, 'next button clicked, selectedIndex at 1' );
  18. prevElem.focus();
  19. prevElem.click();
  20. assert.equal( flkty.selectedIndex, 0, 'previous button clicked, selectedIndex back at 0' );
  21. flkty.select( 5 );
  22. assert.ok( nextElem.disabled, 'next button disabled when at last cell' );
  23. });