1
0
Fork 0

more tests, enable test page scroll overflow #123

This commit is contained in:
Hakim El Hattab 2013-08-22 20:09:40 -04:00
parent c01e1b648b
commit 45fd91f962
2 changed files with 49 additions and 22 deletions

View File

@ -10,7 +10,7 @@
<link rel="stylesheet" href="qunit-1.12.0.css">
</head>
<body>
<body style="overflow: auto;">
<div id="qunit"></div>
<div id="qunit-fixture"></div>

View File

@ -33,27 +33,27 @@ Reveal.addEventListener( 'ready', function() {
});
test( 'Reveal.isFirstSlide', function() {
Reveal.slide( 0 );
strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 0 )' );
Reveal.slide( 0, 0 );
strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 0, 0 )' );
Reveal.slide( 1 );
strictEqual( Reveal.isFirstSlide(), false, 'false after Reveal.slide( 1 )' );
Reveal.slide( 1, 0 );
strictEqual( Reveal.isFirstSlide(), false, 'false after Reveal.slide( 1, 0 )' );
Reveal.slide( 0 );
strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 0 )' );
Reveal.slide( 0, 0 );
strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 0, 0 )' );
});
test( 'Reveal.isLastSlide', function() {
Reveal.slide( 0 );
strictEqual( Reveal.isLastSlide(), false, 'false after Reveal.slide( 0 )' );
Reveal.slide( 0, 0 );
strictEqual( Reveal.isLastSlide(), false, 'false after Reveal.slide( 0, 0 )' );
var lastSlideIndex = document.querySelectorAll( '.reveal .slides>section' ).length - 1;
Reveal.slide( lastSlideIndex );
strictEqual( Reveal.isLastSlide(), true, 'true after Reveal.slide( '+ lastSlideIndex +' )' );
Reveal.slide( lastSlideIndex, 0 );
strictEqual( Reveal.isLastSlide(), true, 'true after Reveal.slide( ', 0+ lastSlideIndex +' )' );
Reveal.slide( 0 );
strictEqual( Reveal.isLastSlide(), false, 'false after Reveal.slide( 0 )' );
Reveal.slide( 0, 0 );
strictEqual( Reveal.isLastSlide(), false, 'false after Reveal.slide( 0, 0 )' );
});
test( 'Reveal.getIndices', function() {
@ -63,13 +63,32 @@ Reveal.addEventListener( 'ready', function() {
ok( typeof indices.hasOwnProperty( 'v' ), 'v exists' );
ok( typeof indices.hasOwnProperty( 'f' ), 'f exists' );
Reveal.slide( 1 );
Reveal.slide( 1, 0 );
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' );
Reveal.slide( 0 );
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' );
});
test( 'Reveal.getScale', function() {
@ -80,11 +99,6 @@ Reveal.addEventListener( 'ready', function() {
ok( typeof Reveal.getConfig() === 'object', 'has config' );
});
test( 'Reveal.availableRoutes', function() {
Reveal.slide( 0 );
deepEqual( Reveal.availableRoutes(), { left: false, up: false, down: false, right: true }, 'correct for first slide' );
});
test( 'Reveal.configure', function() {
strictEqual( Reveal.getConfig().loop, false, '"loop" is false to start with' );
@ -95,6 +109,19 @@ Reveal.addEventListener( 'ready', function() {
strictEqual( Reveal.getConfig().customTestValue, 1, 'supports custom values' );
});
test( 'Reveal.availableRoutes', function() {
Reveal.slide( 0, 0 );
deepEqual( Reveal.availableRoutes(), { left: false, up: false, down: false, right: true }, 'correct for first slide' );
});
// ---------------------------------------------------------------
// TODO: FRAGMENT TESTS
// ---------------------------------------------------------------
// TODO: CONFIGURATION VALUES
// ---------------------------------------------------------------
// EVENT TESTS
@ -112,10 +139,10 @@ Reveal.addEventListener( 'ready', function() {
Reveal.addEventListener( 'slidechanged', _onSlideChanged );
// Should trigger the event
Reveal.slide( 1 );
Reveal.slide( 1, 0 );
// Should not trigger an event since it's the same #
Reveal.slide( 1 );
Reveal.slide( 1, 0 );
Reveal.removeEventListener( 'slidechanged', _onSlideChanged );