group-cells.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. QUnit.test( 'groupCells', function( assert ) {
  2. 'use strict';
  3. var flkty = new Flickity( '#group-cells', {
  4. groupCells: true
  5. });
  6. function getSlideCellsCount() {
  7. var counts = flkty.slides.map( function( slide ) {
  8. return slide.cells.length;
  9. });
  10. return counts.join(',');
  11. }
  12. assert.equal( getSlideCellsCount(), '3,2,2,1,1,3,2', 'groupCells: true' );
  13. var targets = flkty.slides.map( function( slide ) {
  14. return slide.target;
  15. });
  16. assert.deepEqual( targets, [200, 600, 1000, 1300, 1600, 2000, 2300], 'targets' );
  17. flkty.selectCell( 6 );
  18. assert.equal( flkty.selectedIndex, 2, 'selectCell(6) selects 3rd slide' );
  19. flkty.selectCell( flkty.cells[2].element );
  20. assert.equal( flkty.selectedIndex, 0, 'selectCell(3rd elem) selects 1st slide' );
  21. flkty.options.groupCells = 2;
  22. flkty.reposition();
  23. assert.equal( getSlideCellsCount(), '2,2,2,2,2,2,2', 'groupCells: 2' );
  24. flkty.options.groupCells = '75%';
  25. flkty.reposition();
  26. assert.equal( getSlideCellsCount(), '2,1,1,2,1,1,1,2,2,1', 'groupCells: 75%' );
  27. flkty.element.classList.add('is-expanded'); // 600px wide
  28. flkty.options.groupCells = true;
  29. flkty.resize();
  30. assert.equal( getSlideCellsCount(), '3,3,2,3,3', 'groupCells: true, container @ 600px' );
  31. });