2013-08-22 23:03:11 +00:00
|
|
|
|
2013-08-23 00:27:41 +00:00
|
|
|
// These tests expect the DOM to contain a presentation
|
|
|
|
// with the following slide structure:
|
|
|
|
//
|
|
|
|
// 1
|
|
|
|
// 2 - Three sub-slides
|
|
|
|
// 3 - Three fragment elements
|
2013-11-25 19:45:14 +00:00
|
|
|
// 3 - Two fragments with same data-fragment-index
|
2013-08-23 00:27:41 +00:00
|
|
|
// 4
|
|
|
|
|
2013-08-22 23:03:11 +00:00
|
|
|
|
|
|
|
Reveal.addEventListener( 'ready', function() {
|
|
|
|
|
2013-11-28 16:31:16 +00:00
|
|
|
// ---------------------------------------------------------------
|
|
|
|
// DOM TESTS
|
|
|
|
|
|
|
|
QUnit.module( 'DOM' );
|
|
|
|
|
|
|
|
test( 'Initial slides classes', function() {
|
|
|
|
var horizontalSlides = document.querySelectorAll( '.reveal .slides>section' )
|
|
|
|
|
|
|
|
strictEqual( document.querySelectorAll( '.reveal .slides section.past' ).length, 0, 'no .past slides' );
|
|
|
|
strictEqual( document.querySelectorAll( '.reveal .slides section.present' ).length, 1, 'one .present slide' );
|
|
|
|
strictEqual( document.querySelectorAll( '.reveal .slides>section.future' ).length, horizontalSlides.length - 1, 'remaining horizontal slides are .future' );
|
|
|
|
|
|
|
|
strictEqual( document.querySelectorAll( '.reveal .slides section.stack' ).length, 2, 'two .stacks' );
|
|
|
|
|
|
|
|
ok( document.querySelectorAll( '.reveal .slides section.stack' )[0].querySelectorAll( '.future' ).length > 0, 'vertical slides are given .future' );
|
|
|
|
});
|
2013-08-22 23:51:00 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
// API TESTS
|
|
|
|
|
2013-08-22 23:03:11 +00:00
|
|
|
QUnit.module( 'API' );
|
|
|
|
|
|
|
|
test( 'Reveal.isReady', function() {
|
2013-08-22 23:51:00 +00:00
|
|
|
strictEqual( Reveal.isReady(), true, 'returns true' );
|
2013-08-22 23:03:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( 'Reveal.isOverview', function() {
|
2013-08-22 23:51:00 +00:00
|
|
|
strictEqual( Reveal.isOverview(), false, 'false by default' );
|
2013-08-22 23:03:11 +00:00
|
|
|
|
|
|
|
Reveal.toggleOverview();
|
2013-08-22 23:51:00 +00:00
|
|
|
strictEqual( Reveal.isOverview(), true, 'true after toggling on' );
|
2013-08-22 23:03:11 +00:00
|
|
|
|
|
|
|
Reveal.toggleOverview();
|
2013-08-22 23:51:00 +00:00
|
|
|
strictEqual( Reveal.isOverview(), false, 'false after toggling off' );
|
2013-08-22 23:03:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( 'Reveal.isPaused', function() {
|
2013-08-22 23:51:00 +00:00
|
|
|
strictEqual( Reveal.isPaused(), false, 'false by default' );
|
2013-08-22 23:03:11 +00:00
|
|
|
|
|
|
|
Reveal.togglePause();
|
2013-08-22 23:51:00 +00:00
|
|
|
strictEqual( Reveal.isPaused(), true, 'true after pausing' );
|
2013-08-22 23:03:11 +00:00
|
|
|
|
|
|
|
Reveal.togglePause();
|
2013-08-22 23:51:00 +00:00
|
|
|
strictEqual( Reveal.isPaused(), false, 'false after resuming' );
|
2013-08-22 23:03:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( 'Reveal.isFirstSlide', function() {
|
2013-08-23 00:09:40 +00:00
|
|
|
Reveal.slide( 0, 0 );
|
|
|
|
strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 0, 0 )' );
|
2013-08-22 23:03:11 +00:00
|
|
|
|
2013-08-23 00:09:40 +00:00
|
|
|
Reveal.slide( 1, 0 );
|
|
|
|
strictEqual( Reveal.isFirstSlide(), false, 'false after Reveal.slide( 1, 0 )' );
|
2013-08-22 23:03:11 +00:00
|
|
|
|
2013-08-23 00:09:40 +00:00
|
|
|
Reveal.slide( 0, 0 );
|
|
|
|
strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 0, 0 )' );
|
2013-08-22 23:03:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( 'Reveal.isLastSlide', function() {
|
2013-08-23 00:09:40 +00:00
|
|
|
Reveal.slide( 0, 0 );
|
|
|
|
strictEqual( Reveal.isLastSlide(), false, 'false after Reveal.slide( 0, 0 )' );
|
2013-08-22 23:03:11 +00:00
|
|
|
|
2013-08-22 23:46:35 +00:00
|
|
|
var lastSlideIndex = document.querySelectorAll( '.reveal .slides>section' ).length - 1;
|
|
|
|
|
2013-08-23 00:09:40 +00:00
|
|
|
Reveal.slide( lastSlideIndex, 0 );
|
|
|
|
strictEqual( Reveal.isLastSlide(), true, 'true after Reveal.slide( ', 0+ lastSlideIndex +' )' );
|
2013-08-22 23:03:11 +00:00
|
|
|
|
2013-08-23 00:09:40 +00:00
|
|
|
Reveal.slide( 0, 0 );
|
|
|
|
strictEqual( Reveal.isLastSlide(), false, 'false after Reveal.slide( 0, 0 )' );
|
2013-08-22 23:03:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( 'Reveal.getIndices', function() {
|
|
|
|
var indices = Reveal.getIndices();
|
|
|
|
|
|
|
|
ok( typeof indices.hasOwnProperty( 'h' ), 'h exists' );
|
|
|
|
ok( typeof indices.hasOwnProperty( 'v' ), 'v exists' );
|
|
|
|
ok( typeof indices.hasOwnProperty( 'f' ), 'f exists' );
|
|
|
|
|
2013-08-23 00:09:40 +00:00
|
|
|
Reveal.slide( 1, 0 );
|
2013-08-22 23:03:11 +00:00
|
|
|
ok( Reveal.getIndices().h === 1 && Reveal.getIndices().v === 0, 'h 1, v 0' );
|
|
|
|
|
|
|
|
Reveal.slide( 1, 2 );
|
|
|
|
ok( Reveal.getIndices().h === 1 && Reveal.getIndices().v === 2, 'h 1, v 2' );
|
|
|
|
|
2013-08-23 00:09:40 +00:00
|
|
|
Reveal.slide( 0, 0 );
|
|
|
|
});
|
|
|
|
|
|
|
|
test( 'Reveal.getSlide', function() {
|
|
|
|
var firstSlide = document.querySelector( '.reveal .slides>section:first-child' );
|
|
|
|
|
|
|
|
equal( Reveal.getSlide( 0 ), firstSlide, 'gets correct first slide' );
|
|
|
|
|
|
|
|
strictEqual( Reveal.getSlide( 100 ), undefined, 'returns undefined when slide can\'t be found' );
|
|
|
|
});
|
|
|
|
|
|
|
|
test( 'Reveal.getPreviousSlide/getCurrentSlide', function() {
|
|
|
|
Reveal.slide( 0, 0 );
|
|
|
|
Reveal.slide( 1, 0 );
|
|
|
|
|
|
|
|
var firstSlide = document.querySelector( '.reveal .slides>section:first-child' );
|
|
|
|
var secondSlide = document.querySelector( '.reveal .slides>section:nth-child(2)>section' );
|
|
|
|
|
|
|
|
equal( Reveal.getPreviousSlide(), firstSlide, 'previous is slide #0' );
|
|
|
|
equal( Reveal.getCurrentSlide(), secondSlide, 'current is slide #1' );
|
2013-08-22 23:03:11 +00:00
|
|
|
});
|
|
|
|
|
2014-03-12 21:29:01 +00:00
|
|
|
test( 'Reveal.getProgress', function() {
|
|
|
|
Reveal.slide( 0, 0 );
|
|
|
|
strictEqual( Reveal.getProgress(), 0, 'progress is 0 on first slide' );
|
|
|
|
|
|
|
|
var lastSlideIndex = document.querySelectorAll( '.reveal .slides>section' ).length - 1;
|
|
|
|
|
|
|
|
Reveal.slide( lastSlideIndex, 0 );
|
|
|
|
strictEqual( Reveal.getProgress(), 1, 'progress is 1 on last slide' );
|
|
|
|
});
|
|
|
|
|
2013-08-22 23:03:11 +00:00
|
|
|
test( 'Reveal.getScale', function() {
|
|
|
|
ok( typeof Reveal.getScale() === 'number', 'has scale' );
|
|
|
|
});
|
|
|
|
|
|
|
|
test( 'Reveal.getConfig', function() {
|
|
|
|
ok( typeof Reveal.getConfig() === 'object', 'has config' );
|
|
|
|
});
|
|
|
|
|
2013-08-22 23:51:00 +00:00
|
|
|
test( 'Reveal.configure', function() {
|
|
|
|
strictEqual( Reveal.getConfig().loop, false, '"loop" is false to start with' );
|
|
|
|
|
|
|
|
Reveal.configure({ loop: true });
|
|
|
|
strictEqual( Reveal.getConfig().loop, true, '"loop" has changed to true' );
|
|
|
|
|
|
|
|
Reveal.configure({ loop: false, customTestValue: 1 });
|
|
|
|
strictEqual( Reveal.getConfig().customTestValue, 1, 'supports custom values' );
|
|
|
|
});
|
|
|
|
|
2013-08-23 00:09:40 +00:00
|
|
|
test( 'Reveal.availableRoutes', function() {
|
|
|
|
Reveal.slide( 0, 0 );
|
|
|
|
deepEqual( Reveal.availableRoutes(), { left: false, up: false, down: false, right: true }, 'correct for first slide' );
|
2013-08-23 19:36:16 +00:00
|
|
|
|
|
|
|
Reveal.slide( 1, 0 );
|
|
|
|
deepEqual( Reveal.availableRoutes(), { left: true, up: false, down: true, right: true }, 'correct for vertical slide' );
|
2013-08-23 00:09:40 +00:00
|
|
|
});
|
|
|
|
|
2013-08-23 00:27:41 +00:00
|
|
|
test( 'Reveal.next', function() {
|
|
|
|
Reveal.slide( 0, 0 );
|
|
|
|
|
2013-11-25 19:45:14 +00:00
|
|
|
// Step through vertical child slides
|
2013-08-23 00:27:41 +00:00
|
|
|
Reveal.next();
|
|
|
|
deepEqual( Reveal.getIndices(), { h: 1, v: 0, f: undefined } );
|
|
|
|
|
|
|
|
Reveal.next();
|
|
|
|
deepEqual( Reveal.getIndices(), { h: 1, v: 1, f: undefined } );
|
|
|
|
|
|
|
|
Reveal.next();
|
|
|
|
deepEqual( Reveal.getIndices(), { h: 1, v: 2, f: undefined } );
|
|
|
|
|
2013-11-25 19:45:14 +00:00
|
|
|
// Step through fragments
|
2013-11-21 14:01:18 +00:00
|
|
|
Reveal.next();
|
|
|
|
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: -1 } );
|
|
|
|
|
2013-08-23 00:27:41 +00:00
|
|
|
Reveal.next();
|
|
|
|
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 } );
|
|
|
|
|
|
|
|
Reveal.next();
|
|
|
|
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 } );
|
|
|
|
|
|
|
|
Reveal.next();
|
|
|
|
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 } );
|
2013-11-25 19:45:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( 'Reveal.next at end', function() {
|
|
|
|
Reveal.slide( 3 );
|
2013-08-23 00:27:41 +00:00
|
|
|
|
2013-11-25 19:45:14 +00:00
|
|
|
// We're at the end, this should have no effect
|
2013-08-23 00:27:41 +00:00
|
|
|
Reveal.next();
|
|
|
|
deepEqual( Reveal.getIndices(), { h: 3, v: 0, f: undefined } );
|
|
|
|
|
|
|
|
Reveal.next();
|
|
|
|
deepEqual( Reveal.getIndices(), { h: 3, v: 0, f: undefined } );
|
|
|
|
});
|
|
|
|
|
2013-08-23 00:09:40 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
2013-08-23 19:36:16 +00:00
|
|
|
// FRAGMENT TESTS
|
|
|
|
|
|
|
|
QUnit.module( 'Fragments' );
|
|
|
|
|
|
|
|
test( 'Sliding to fragments', function() {
|
2013-11-23 22:13:14 +00:00
|
|
|
Reveal.slide( 2, 0, -1 );
|
|
|
|
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: -1 }, 'Reveal.slide( 2, 0, -1 )' );
|
|
|
|
|
2013-08-23 19:36:16 +00:00
|
|
|
Reveal.slide( 2, 0, 0 );
|
|
|
|
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'Reveal.slide( 2, 0, 0 )' );
|
|
|
|
|
|
|
|
Reveal.slide( 2, 0, 2 );
|
|
|
|
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 }, 'Reveal.slide( 2, 0, 2 )' );
|
|
|
|
|
|
|
|
Reveal.slide( 2, 0, 1 );
|
|
|
|
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'Reveal.slide( 2, 0, 1 )' );
|
|
|
|
});
|
|
|
|
|
2013-11-23 22:13:14 +00:00
|
|
|
test( 'Hiding all fragments', function() {
|
2013-11-25 19:45:14 +00:00
|
|
|
var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' );
|
2013-11-23 22:13:14 +00:00
|
|
|
|
|
|
|
Reveal.slide( 2, 0, 0 );
|
|
|
|
strictEqual( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 1, 'one fragment visible when index is 0' );
|
|
|
|
|
|
|
|
Reveal.slide( 2, 0, -1 );
|
2013-11-25 19:45:14 +00:00
|
|
|
strictEqual( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 0, 'no fragments visible when index is -1' );
|
2013-11-23 22:13:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test( 'Current fragment', function() {
|
2013-11-25 19:45:14 +00:00
|
|
|
var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' );
|
2013-11-23 22:13:14 +00:00
|
|
|
|
|
|
|
Reveal.slide( 2, 0 );
|
|
|
|
strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 0, 'no current fragment at index -1' );
|
|
|
|
|
|
|
|
Reveal.slide( 2, 0, 0 );
|
|
|
|
strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 1, 'one current fragment at index 0' );
|
|
|
|
|
|
|
|
Reveal.slide( 1, 0, 0 );
|
|
|
|
strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 0, 'no current fragment when navigating to previous slide' );
|
|
|
|
|
|
|
|
Reveal.slide( 3, 0, 0 );
|
|
|
|
strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 0, 'no current fragment when navigating to next slide' );
|
|
|
|
});
|
|
|
|
|
2013-08-23 19:36:16 +00:00
|
|
|
test( 'Stepping through fragments', function() {
|
2013-11-21 14:01:18 +00:00
|
|
|
Reveal.slide( 2, 0, -1 );
|
2013-08-23 19:36:16 +00:00
|
|
|
|
|
|
|
// forwards:
|
|
|
|
|
|
|
|
Reveal.next();
|
2013-11-21 14:01:18 +00:00
|
|
|
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'next() goes to next fragment' );
|
2013-08-23 19:36:16 +00:00
|
|
|
|
|
|
|
Reveal.right();
|
2013-11-21 14:01:18 +00:00
|
|
|
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'right() goes to next fragment' );
|
2013-08-23 19:36:16 +00:00
|
|
|
|
|
|
|
Reveal.down();
|
2013-11-21 14:01:18 +00:00
|
|
|
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 }, 'down() goes to next fragment' );
|
2013-08-23 19:36:16 +00:00
|
|
|
|
|
|
|
Reveal.down(); // moves to f #3
|
|
|
|
|
|
|
|
// backwards:
|
|
|
|
|
|
|
|
Reveal.prev();
|
2013-11-25 19:45:14 +00:00
|
|
|
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 }, 'prev() goes to prev fragment' );
|
2013-08-23 19:36:16 +00:00
|
|
|
|
|
|
|
Reveal.left();
|
2013-11-25 19:45:14 +00:00
|
|
|
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'left() goes to prev fragment' );
|
2013-08-23 19:36:16 +00:00
|
|
|
|
|
|
|
Reveal.up();
|
2013-11-25 19:45:14 +00:00
|
|
|
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'up() goes to prev fragment' );
|
2013-08-23 19:36:16 +00:00
|
|
|
});
|
|
|
|
|
2013-11-07 13:39:19 +00:00
|
|
|
test( 'Stepping past fragments', function() {
|
2013-11-25 20:26:22 +00:00
|
|
|
var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' );
|
2013-11-07 13:39:19 +00:00
|
|
|
|
|
|
|
Reveal.slide( 0, 0, 0 );
|
|
|
|
equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 0, 'no fragments visible when on previous slide' );
|
|
|
|
|
|
|
|
Reveal.slide( 3, 0, 0 );
|
|
|
|
equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 3, 'all fragments visible when on future slide' );
|
|
|
|
});
|
|
|
|
|
2013-11-25 19:45:14 +00:00
|
|
|
test( 'Fragment indices', function() {
|
|
|
|
var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(2)' );
|
|
|
|
|
|
|
|
Reveal.slide( 3, 0, 0 );
|
|
|
|
equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 2, 'both fragments of same index are shown' );
|
|
|
|
});
|
|
|
|
|
2013-11-25 20:26:22 +00:00
|
|
|
test( 'Index generation', function() {
|
|
|
|
var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' );
|
|
|
|
|
|
|
|
// These have no indices defined to start with
|
|
|
|
equal( fragmentSlide.querySelectorAll( '.fragment' )[0].getAttribute( 'data-fragment-index' ), '0' );
|
|
|
|
equal( fragmentSlide.querySelectorAll( '.fragment' )[1].getAttribute( 'data-fragment-index' ), '1' );
|
|
|
|
equal( fragmentSlide.querySelectorAll( '.fragment' )[2].getAttribute( 'data-fragment-index' ), '2' );
|
|
|
|
});
|
|
|
|
|
|
|
|
test( 'Index normalization', function() {
|
|
|
|
var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(3)' );
|
|
|
|
|
|
|
|
// These start out as 1-4-4 and should normalize to 0-1-1
|
|
|
|
equal( fragmentSlide.querySelectorAll( '.fragment' )[0].getAttribute( 'data-fragment-index' ), '0' );
|
|
|
|
equal( fragmentSlide.querySelectorAll( '.fragment' )[1].getAttribute( 'data-fragment-index' ), '1' );
|
|
|
|
equal( fragmentSlide.querySelectorAll( '.fragment' )[2].getAttribute( 'data-fragment-index' ), '1' );
|
|
|
|
});
|
|
|
|
|
2013-08-23 19:36:16 +00:00
|
|
|
asyncTest( 'fragmentshown event', function() {
|
|
|
|
expect( 2 );
|
|
|
|
|
|
|
|
var _onEvent = function( event ) {
|
|
|
|
ok( true, 'event fired' );
|
|
|
|
}
|
|
|
|
|
|
|
|
Reveal.addEventListener( 'fragmentshown', _onEvent );
|
|
|
|
|
|
|
|
Reveal.slide( 2, 0 );
|
|
|
|
Reveal.slide( 2, 0 ); // should do nothing
|
|
|
|
Reveal.slide( 2, 0, 0 ); // should do nothing
|
|
|
|
Reveal.next();
|
|
|
|
Reveal.next();
|
|
|
|
Reveal.prev(); // shouldn't fire fragmentshown
|
|
|
|
|
2013-08-24 14:52:35 +00:00
|
|
|
start();
|
|
|
|
|
2013-08-23 19:36:16 +00:00
|
|
|
Reveal.removeEventListener( 'fragmentshown', _onEvent );
|
|
|
|
});
|
|
|
|
|
|
|
|
asyncTest( 'fragmenthidden event', function() {
|
|
|
|
expect( 2 );
|
|
|
|
|
|
|
|
var _onEvent = function( event ) {
|
|
|
|
ok( true, 'event fired' );
|
|
|
|
}
|
|
|
|
|
|
|
|
Reveal.addEventListener( 'fragmenthidden', _onEvent );
|
|
|
|
|
|
|
|
Reveal.slide( 2, 0, 2 );
|
|
|
|
Reveal.slide( 2, 0, 2 ); // should do nothing
|
|
|
|
Reveal.prev();
|
|
|
|
Reveal.prev();
|
|
|
|
Reveal.next(); // shouldn't fire fragmenthidden
|
|
|
|
|
2013-08-23 19:57:28 +00:00
|
|
|
start();
|
|
|
|
|
2013-08-23 19:36:16 +00:00
|
|
|
Reveal.removeEventListener( 'fragmenthidden', _onEvent );
|
|
|
|
});
|
2013-08-23 00:09:40 +00:00
|
|
|
|
|
|
|
|
2013-12-21 17:08:40 +00:00
|
|
|
// ---------------------------------------------------------------
|
|
|
|
// AUTO-SLIDE TESTS
|
|
|
|
|
|
|
|
QUnit.module( 'Auto Sliding' );
|
|
|
|
|
|
|
|
test( 'Reveal.isAutoSliding', function() {
|
|
|
|
strictEqual( Reveal.isAutoSliding(), false, 'false by default' );
|
|
|
|
|
|
|
|
Reveal.configure({ autoSlide: 10000 });
|
|
|
|
strictEqual( Reveal.isAutoSliding(), true, 'true after starting' );
|
|
|
|
|
|
|
|
Reveal.configure({ autoSlide: 0 });
|
|
|
|
strictEqual( Reveal.isAutoSliding(), false, 'false after setting to 0' );
|
|
|
|
});
|
|
|
|
|
|
|
|
test( 'Reveal.toggleAutoSlide', function() {
|
|
|
|
Reveal.configure({ autoSlide: 10000 });
|
|
|
|
|
|
|
|
Reveal.toggleAutoSlide();
|
|
|
|
strictEqual( Reveal.isAutoSliding(), false, 'false after first toggle' );
|
|
|
|
Reveal.toggleAutoSlide();
|
|
|
|
strictEqual( Reveal.isAutoSliding(), true, 'true after second toggle' );
|
|
|
|
|
|
|
|
Reveal.configure({ autoSlide: 0 });
|
|
|
|
});
|
|
|
|
|
|
|
|
asyncTest( 'autoslidepaused', function() {
|
|
|
|
expect( 1 );
|
|
|
|
|
|
|
|
var _onEvent = function( event ) {
|
|
|
|
ok( true, 'event fired' );
|
|
|
|
}
|
|
|
|
|
|
|
|
Reveal.addEventListener( 'autoslidepaused', _onEvent );
|
|
|
|
Reveal.configure({ autoSlide: 10000 });
|
|
|
|
Reveal.toggleAutoSlide();
|
|
|
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
// cleanup
|
|
|
|
Reveal.configure({ autoSlide: 0 });
|
|
|
|
Reveal.removeEventListener( 'autoslidepaused', _onEvent );
|
|
|
|
});
|
|
|
|
|
|
|
|
asyncTest( 'autoslideresumed', function() {
|
|
|
|
expect( 1 );
|
|
|
|
|
|
|
|
var _onEvent = function( event ) {
|
|
|
|
ok( true, 'event fired' );
|
|
|
|
}
|
|
|
|
|
|
|
|
Reveal.addEventListener( 'autoslideresumed', _onEvent );
|
|
|
|
Reveal.configure({ autoSlide: 10000 });
|
|
|
|
Reveal.toggleAutoSlide();
|
|
|
|
Reveal.toggleAutoSlide();
|
|
|
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
// cleanup
|
|
|
|
Reveal.configure({ autoSlide: 0 });
|
|
|
|
Reveal.removeEventListener( 'autoslideresumed', _onEvent );
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2013-08-23 00:09:40 +00:00
|
|
|
// ---------------------------------------------------------------
|
2013-08-23 00:27:41 +00:00
|
|
|
// CONFIGURATION VALUES
|
|
|
|
|
|
|
|
QUnit.module( 'Configuration' );
|
|
|
|
|
|
|
|
test( 'Controls', function() {
|
|
|
|
var controlsElement = document.querySelector( '.reveal>.controls' );
|
|
|
|
|
|
|
|
Reveal.configure({ controls: false });
|
|
|
|
equal( controlsElement.style.display, 'none', 'controls are hidden' );
|
|
|
|
|
|
|
|
Reveal.configure({ controls: true });
|
|
|
|
equal( controlsElement.style.display, 'block', 'controls are visible' );
|
|
|
|
});
|
|
|
|
|
|
|
|
test( 'Progress', function() {
|
|
|
|
var progressElement = document.querySelector( '.reveal>.progress' );
|
|
|
|
|
|
|
|
Reveal.configure({ progress: false });
|
|
|
|
equal( progressElement.style.display, 'none', 'progress are hidden' );
|
|
|
|
|
|
|
|
Reveal.configure({ progress: true });
|
|
|
|
equal( progressElement.style.display, 'block', 'progress are visible' );
|
|
|
|
});
|
2013-08-23 00:09:40 +00:00
|
|
|
|
2013-08-23 01:38:37 +00:00
|
|
|
test( 'Loop', function() {
|
|
|
|
Reveal.configure({ loop: true });
|
|
|
|
|
|
|
|
Reveal.slide( 0, 0 );
|
|
|
|
|
|
|
|
Reveal.left();
|
|
|
|
notEqual( Reveal.getIndices().h, 0, 'looped from start to end' );
|
|
|
|
|
|
|
|
Reveal.right();
|
|
|
|
equal( Reveal.getIndices().h, 0, 'looped from end to start' );
|
|
|
|
|
|
|
|
Reveal.configure({ loop: false });
|
|
|
|
});
|
|
|
|
|
2013-08-22 23:51:00 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
// EVENT TESTS
|
2013-08-22 23:03:11 +00:00
|
|
|
|
|
|
|
QUnit.module( 'Events' );
|
|
|
|
|
|
|
|
asyncTest( 'slidechanged', function() {
|
2013-08-23 19:57:28 +00:00
|
|
|
expect( 3 );
|
2013-08-22 23:03:11 +00:00
|
|
|
|
2013-08-23 19:36:16 +00:00
|
|
|
var _onEvent = function( event ) {
|
2013-08-22 23:03:11 +00:00
|
|
|
ok( true, 'event fired' );
|
|
|
|
}
|
|
|
|
|
2013-08-23 19:36:16 +00:00
|
|
|
Reveal.addEventListener( 'slidechanged', _onEvent );
|
2013-08-22 23:03:11 +00:00
|
|
|
|
2013-08-23 19:57:28 +00:00
|
|
|
Reveal.slide( 1, 0 ); // should trigger
|
|
|
|
Reveal.slide( 1, 0 ); // should do nothing
|
|
|
|
Reveal.next(); // should trigger
|
|
|
|
Reveal.slide( 3, 0 ); // should trigger
|
|
|
|
Reveal.next(); // should do nothing
|
2013-08-22 23:03:11 +00:00
|
|
|
|
2013-08-23 19:57:28 +00:00
|
|
|
start();
|
2013-08-22 23:03:11 +00:00
|
|
|
|
2013-08-23 19:36:16 +00:00
|
|
|
Reveal.removeEventListener( 'slidechanged', _onEvent );
|
2013-08-22 23:03:11 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2013-08-23 19:57:28 +00:00
|
|
|
asyncTest( 'paused', function() {
|
|
|
|
expect( 1 );
|
|
|
|
|
|
|
|
var _onEvent = function( event ) {
|
|
|
|
ok( true, 'event fired' );
|
|
|
|
}
|
|
|
|
|
|
|
|
Reveal.addEventListener( 'paused', _onEvent );
|
|
|
|
|
|
|
|
Reveal.togglePause();
|
|
|
|
Reveal.togglePause();
|
|
|
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
Reveal.removeEventListener( 'paused', _onEvent );
|
|
|
|
});
|
|
|
|
|
|
|
|
asyncTest( 'resumed', function() {
|
|
|
|
expect( 1 );
|
|
|
|
|
|
|
|
var _onEvent = function( event ) {
|
|
|
|
ok( true, 'event fired' );
|
|
|
|
}
|
|
|
|
|
|
|
|
Reveal.addEventListener( 'resumed', _onEvent );
|
|
|
|
|
|
|
|
Reveal.togglePause();
|
|
|
|
Reveal.togglePause();
|
|
|
|
|
|
|
|
start();
|
|
|
|
|
|
|
|
Reveal.removeEventListener( 'resumed', _onEvent );
|
|
|
|
});
|
|
|
|
|
2013-08-22 23:51:00 +00:00
|
|
|
|
2013-08-22 23:03:11 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
Reveal.initialize();
|
|
|
|
|