From f9d076663746ab29410e9c141a7b9e927e4eb5df Mon Sep 17 00:00:00 2001 From: Benjamin Tan Date: Mon, 22 Jan 2018 22:35:15 +0800 Subject: Update QUnit to 2.5.0 and `grunt-contrib-qunit` to 2.0.0. --- test/test.js | 372 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 184 insertions(+), 188 deletions(-) (limited to 'test/test.js') diff --git a/test/test.js b/test/test.js index a96b70b..042e4e8 100644 --- a/test/test.js +++ b/test/test.js @@ -1,4 +1,3 @@ - // These tests expect the DOM to contain a presentation // with the following slide structure: // @@ -8,7 +7,6 @@ // 3 - Two fragments with same data-fragment-index // 4 - Reveal.addEventListener( 'ready', function() { // --------------------------------------------------------------- @@ -16,16 +14,16 @@ Reveal.addEventListener( 'ready', function() { QUnit.module( 'DOM' ); - test( 'Initial slides classes', function() { + QUnit.test( 'Initial slides classes', function( assert ) { 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' ); + assert.strictEqual( document.querySelectorAll( '.reveal .slides section.past' ).length, 0, 'no .past slides' ); + assert.strictEqual( document.querySelectorAll( '.reveal .slides section.present' ).length, 1, 'one .present slide' ); + assert.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' ); + assert.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' ); + assert.ok( document.querySelectorAll( '.reveal .slides section.stack' )[0].querySelectorAll( '.future' ).length > 0, 'vertical slides are given .future' ); }); // --------------------------------------------------------------- @@ -33,203 +31,203 @@ Reveal.addEventListener( 'ready', function() { QUnit.module( 'API' ); - test( 'Reveal.isReady', function() { - strictEqual( Reveal.isReady(), true, 'returns true' ); + QUnit.test( 'Reveal.isReady', function( assert ) { + assert.strictEqual( Reveal.isReady(), true, 'returns true' ); }); - test( 'Reveal.isOverview', function() { - strictEqual( Reveal.isOverview(), false, 'false by default' ); + QUnit.test( 'Reveal.isOverview', function( assert ) { + assert.strictEqual( Reveal.isOverview(), false, 'false by default' ); Reveal.toggleOverview(); - strictEqual( Reveal.isOverview(), true, 'true after toggling on' ); + assert.strictEqual( Reveal.isOverview(), true, 'true after toggling on' ); Reveal.toggleOverview(); - strictEqual( Reveal.isOverview(), false, 'false after toggling off' ); + assert.strictEqual( Reveal.isOverview(), false, 'false after toggling off' ); }); - test( 'Reveal.isPaused', function() { - strictEqual( Reveal.isPaused(), false, 'false by default' ); + QUnit.test( 'Reveal.isPaused', function( assert ) { + assert.strictEqual( Reveal.isPaused(), false, 'false by default' ); Reveal.togglePause(); - strictEqual( Reveal.isPaused(), true, 'true after pausing' ); + assert.strictEqual( Reveal.isPaused(), true, 'true after pausing' ); Reveal.togglePause(); - strictEqual( Reveal.isPaused(), false, 'false after resuming' ); + assert.strictEqual( Reveal.isPaused(), false, 'false after resuming' ); }); - test( 'Reveal.isFirstSlide', function() { + QUnit.test( 'Reveal.isFirstSlide', function( assert ) { Reveal.slide( 0, 0 ); - strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 0, 0 )' ); + assert.strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 0, 0 )' ); Reveal.slide( 1, 0 ); - strictEqual( Reveal.isFirstSlide(), false, 'false after Reveal.slide( 1, 0 )' ); + assert.strictEqual( Reveal.isFirstSlide(), false, 'false after Reveal.slide( 1, 0 )' ); Reveal.slide( 0, 0 ); - strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 0, 0 )' ); + assert.strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 0, 0 )' ); }); - test( 'Reveal.isFirstSlide after vertical slide', function() { + QUnit.test( 'Reveal.isFirstSlide after vertical slide', function( assert ) { Reveal.slide( 1, 1 ); Reveal.slide( 0, 0 ); - strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 1, 1 ) and then Reveal.slide( 0, 0 )' ); + assert.strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 1, 1 ) and then Reveal.slide( 0, 0 )' ); }); - test( 'Reveal.isLastSlide', function() { + QUnit.test( 'Reveal.isLastSlide', function( assert ) { Reveal.slide( 0, 0 ); - strictEqual( Reveal.isLastSlide(), false, 'false after Reveal.slide( 0, 0 )' ); + assert.strictEqual( Reveal.isLastSlide(), false, 'false after Reveal.slide( 0, 0 )' ); var lastSlideIndex = document.querySelectorAll( '.reveal .slides>section' ).length - 1; Reveal.slide( lastSlideIndex, 0 ); - strictEqual( Reveal.isLastSlide(), true, 'true after Reveal.slide( '+ lastSlideIndex +', 0 )' ); + assert.strictEqual( Reveal.isLastSlide(), true, 'true after Reveal.slide( '+ lastSlideIndex +', 0 )' ); Reveal.slide( 0, 0 ); - strictEqual( Reveal.isLastSlide(), false, 'false after Reveal.slide( 0, 0 )' ); + assert.strictEqual( Reveal.isLastSlide(), false, 'false after Reveal.slide( 0, 0 )' ); }); - test( 'Reveal.isLastSlide after vertical slide', function() { + QUnit.test( 'Reveal.isLastSlide after vertical slide', function( assert ) { var lastSlideIndex = document.querySelectorAll( '.reveal .slides>section' ).length - 1; Reveal.slide( 1, 1 ); Reveal.slide( lastSlideIndex ); - strictEqual( Reveal.isLastSlide(), true, 'true after Reveal.slide( 1, 1 ) and then Reveal.slide( '+ lastSlideIndex +', 0 )' ); + assert.strictEqual( Reveal.isLastSlide(), true, 'true after Reveal.slide( 1, 1 ) and then Reveal.slide( '+ lastSlideIndex +', 0 )' ); }); - test( 'Reveal.getTotalSlides', function() { - strictEqual( Reveal.getTotalSlides(), 8, 'eight slides in total' ); + QUnit.test( 'Reveal.getTotalSlides', function( assert ) { + assert.strictEqual( Reveal.getTotalSlides(), 8, 'eight slides in total' ); }); - test( 'Reveal.getIndices', function() { + QUnit.test( 'Reveal.getIndices', function( assert ) { var indices = Reveal.getIndices(); - ok( indices.hasOwnProperty( 'h' ), 'h exists' ); - ok( indices.hasOwnProperty( 'v' ), 'v exists' ); - ok( indices.hasOwnProperty( 'f' ), 'f exists' ); + assert.ok( indices.hasOwnProperty( 'h' ), 'h exists' ); + assert.ok( indices.hasOwnProperty( 'v' ), 'v exists' ); + assert.ok( indices.hasOwnProperty( 'f' ), 'f exists' ); Reveal.slide( 1, 0 ); - strictEqual( Reveal.getIndices().h, 1, 'h 1' ); - strictEqual( Reveal.getIndices().v, 0, 'v 0' ); + assert.strictEqual( Reveal.getIndices().h, 1, 'h 1' ); + assert.strictEqual( Reveal.getIndices().v, 0, 'v 0' ); Reveal.slide( 1, 2 ); - strictEqual( Reveal.getIndices().h, 1, 'h 1' ); - strictEqual( Reveal.getIndices().v, 2, 'v 2' ); + assert.strictEqual( Reveal.getIndices().h, 1, 'h 1' ); + assert.strictEqual( Reveal.getIndices().v, 2, 'v 2' ); Reveal.slide( 0, 0 ); - strictEqual( Reveal.getIndices().h, 0, 'h 0' ); - strictEqual( Reveal.getIndices().v, 0, 'v 0' ); + assert.strictEqual( Reveal.getIndices().h, 0, 'h 0' ); + assert.strictEqual( Reveal.getIndices().v, 0, 'v 0' ); }); - test( 'Reveal.getSlide', function() { - equal( Reveal.getSlide( 0 ), document.querySelector( '.reveal .slides>section:first-child' ), 'gets correct first slide' ); - equal( Reveal.getSlide( 1 ), document.querySelector( '.reveal .slides>section:nth-child(2)' ), 'no v index returns stack' ); - equal( Reveal.getSlide( 1, 0 ), document.querySelector( '.reveal .slides>section:nth-child(2)>section:nth-child(1)' ), 'v index 0 returns first vertical child' ); - equal( Reveal.getSlide( 1, 1 ), document.querySelector( '.reveal .slides>section:nth-child(2)>section:nth-child(2)' ), 'v index 1 returns second vertical child' ); + QUnit.test( 'Reveal.getSlide', function( assert ) { + assert.equal( Reveal.getSlide( 0 ), document.querySelector( '.reveal .slides>section:first-child' ), 'gets correct first slide' ); + assert.equal( Reveal.getSlide( 1 ), document.querySelector( '.reveal .slides>section:nth-child(2)' ), 'no v index returns stack' ); + assert.equal( Reveal.getSlide( 1, 0 ), document.querySelector( '.reveal .slides>section:nth-child(2)>section:nth-child(1)' ), 'v index 0 returns first vertical child' ); + assert.equal( Reveal.getSlide( 1, 1 ), document.querySelector( '.reveal .slides>section:nth-child(2)>section:nth-child(2)' ), 'v index 1 returns second vertical child' ); - strictEqual( Reveal.getSlide( 100 ), undefined, 'undefined when out of horizontal bounds' ); - strictEqual( Reveal.getSlide( 1, 100 ), undefined, 'undefined when out of vertical bounds' ); + assert.strictEqual( Reveal.getSlide( 100 ), undefined, 'undefined when out of horizontal bounds' ); + assert.strictEqual( Reveal.getSlide( 1, 100 ), undefined, 'undefined when out of vertical bounds' ); }); - test( 'Reveal.getSlideBackground', function() { - equal( Reveal.getSlideBackground( 0 ), document.querySelector( '.reveal .backgrounds>.slide-background:first-child' ), 'gets correct first background' ); - equal( Reveal.getSlideBackground( 1 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2)' ), 'no v index returns stack' ); - equal( Reveal.getSlideBackground( 1, 0 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2) .slide-background:nth-child(1)' ), 'v index 0 returns first vertical child' ); - equal( Reveal.getSlideBackground( 1, 1 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2) .slide-background:nth-child(2)' ), 'v index 1 returns second vertical child' ); + QUnit.test( 'Reveal.getSlideBackground', function( assert ) { + assert.equal( Reveal.getSlideBackground( 0 ), document.querySelector( '.reveal .backgrounds>.slide-background:first-child' ), 'gets correct first background' ); + assert.equal( Reveal.getSlideBackground( 1 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2)' ), 'no v index returns stack' ); + assert.equal( Reveal.getSlideBackground( 1, 0 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2) .slide-background:nth-child(1)' ), 'v index 0 returns first vertical child' ); + assert.equal( Reveal.getSlideBackground( 1, 1 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2) .slide-background:nth-child(2)' ), 'v index 1 returns second vertical child' ); - strictEqual( Reveal.getSlideBackground( 100 ), undefined, 'undefined when out of horizontal bounds' ); - strictEqual( Reveal.getSlideBackground( 1, 100 ), undefined, 'undefined when out of vertical bounds' ); + assert.strictEqual( Reveal.getSlideBackground( 100 ), undefined, 'undefined when out of horizontal bounds' ); + assert.strictEqual( Reveal.getSlideBackground( 1, 100 ), undefined, 'undefined when out of vertical bounds' ); }); - test( 'Reveal.getSlideNotes', function() { + QUnit.test( 'Reveal.getSlideNotes', function( assert ) { Reveal.slide( 0, 0 ); - ok( Reveal.getSlideNotes() === 'speaker notes 1', 'works with