initial-index.js 896 B

1234567891011121314151617181920212223242526
  1. QUnit.test( 'initialIndex', function( assert ) {
  2. 'use strict';
  3. // initialIndex number
  4. var flkty = new Flickity( '#initial-index', {
  5. initialIndex: 3,
  6. });
  7. assert.equal( flkty.selectedIndex, 3, 'initialIndex number' );
  8. // selectedIndex remains same after reactivation
  9. flkty.deactivate();
  10. flkty.activate();
  11. assert.equal( flkty.selectedIndex, 3, 'reactivated selectedIndex stays the same' );
  12. flkty.destroy();
  13. // initialIndex selector string
  14. flkty = new Flickity( '#initial-index', {
  15. initialIndex: '.cell--initial',
  16. });
  17. assert.equal( flkty.selectedIndex, 4, 'initialIndex selector string' );
  18. flkty.destroy();
  19. // initialIndex selector string with groupCells #881
  20. flkty = new Flickity( '#initial-index', {
  21. groupCells: 3,
  22. initialIndex: '.cell--initial',
  23. });
  24. assert.equal( flkty.selectedIndex, 1, 'initialIndex selector string with groupCells' );
  25. });