1234567891011121314151617181920212223242526272829303132333435363738 |
- import { minimum } from '../data/html';
- import Splide from '../../src/js/splide';
- import { COMPLETE } from '../../src/js/components';
- describe( 'Splide with "focus" option', () => {
- let splide;
- beforeEach( () => {
- document.body.innerHTML = minimum;
- splide = new Splide( '#splide' ).mount( COMPLETE );
- } );
- test( 'should locate the active slide on the center of the slider if the value is "center".', () => {
- const { Track, Elements: { track } } = splide.Components;
- const width = 900;
- const perView = 3;
- const slideWidth = width / perView;
- Object.defineProperty( track, 'clientWidth', { value: width } );
- splide.options = { focus: 'center', perView };
- expect( Track.offset ).toBe( - ( width / 2 - slideWidth / 2 ) );
- } );
- test( 'should locate the active slide according to the focus index.', () => {
- const { Track, Elements: { track } } = splide.Components;
- const width = 900;
- const perView = 3;
- const focus = 2;
- const slideWidth = width / perView;
- Object.defineProperty( track, 'clientWidth', { value: width } );
- splide.options = { focus, perView };
- expect( Track.offset ).toBe( - slideWidth * focus );
- } );
- } );
|