UNPKG

flickity

Version:

Touch, responsive, flickable carousels

30 lines (25 loc) 1.18 kB
QUnit.test( 'prev-next-buttons', function( assert ) { let elem = document.querySelector('#prev-next-buttons'); let flkty = new Flickity( elem ); let prevElem = elem.querySelector('.flickity-prev-next-button.previous'); let nextElem = elem.querySelector('.flickity-prev-next-button.next'); assert.ok( prevElem, 'previous button in DOM' ); assert.ok( nextElem, 'next button in DOM' ); assert.equal( flkty.prevButton.element, prevElem, 'previous button element matches prevButton.element' ); assert.equal( flkty.nextButton.element, nextElem, 'next button element matches nextButton.element' ); assert.ok( prevElem.disabled, 'previous button is disabled at first index' ); prevElem.focus(); prevElem.click(); assert.equal( flkty.selectedIndex, 0, 'selectedIndex still at 0' ); nextElem.focus(); nextElem.click(); assert.equal( flkty.selectedIndex, 1, 'next button clicked, selectedIndex at 1' ); prevElem.focus(); prevElem.click(); assert.equal( flkty.selectedIndex, 0, 'previous button clicked, selectedIndex back at 0' ); flkty.select( 5 ); assert.ok( nextElem.disabled, 'next button disabled when at last cell' ); } );