init.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. ( function() {
  2. 'use strict';
  3. QUnit.module('Flickity');
  4. var utils = window.fizzyUIUtils;
  5. QUnit.test( 'init', function( assert ) {
  6. var elem = document.querySelector('#init');
  7. var flkty = new Flickity( elem );
  8. for ( var prop in Flickity.defaults ) {
  9. assert.equal( flkty.options[ prop ], Flickity.defaults[ prop ], prop + ' option matches default' );
  10. }
  11. assert.equal( flkty.element, elem, '.element is proper element' );
  12. var children = utils.makeArray( flkty.element.children );
  13. assert.notEqual( children.indexOf( flkty.viewport ), -1, 'viewport element is a child element' );
  14. assert.equal( flkty.viewport.children[0], flkty.slider, 'slider is in viewport' );
  15. assert.equal( flkty.viewport.style.height, '100px', 'viewport height set' );
  16. assert.ok( flkty.isActive, 'isActive' );
  17. assert.ok( matchesSelector( elem, '.flickity-enabled' ), 'flickity-enabled class added' );
  18. assert.equal( flkty.cells.length, 6, 'has 6 cells' );
  19. assert.equal( flkty.cells[0].element.style.left, '0%', 'first cell left: 0%' );
  20. assert.equal( flkty.cells[5].element.style.left, '500%', '6th cell left: 500%' );
  21. assert.equal( flkty.selectedIndex, 0, 'selectedIndex = 0' );
  22. assert.equal( flkty.cursorPosition, 200, 'cursorPosition = 200' );
  23. assert.equal( flkty.x + flkty.cursorPosition, 0, 'x + cursorPosition = 0' );
  24. });
  25. })();