From 3427561b64a45716e897758509bf23a743492dda Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Mon, 25 Nov 2013 14:45:14 -0500 Subject: rewrite fragment sorting to account for multiple fragments with the same index --- test/test.html | 33 ++++++++++++++++++++++++++------- test/test.js | 32 ++++++++++++++++++++++---------- 2 files changed, 48 insertions(+), 17 deletions(-) (limited to 'test') diff --git a/test/test.html b/test/test.html index 81d2f16..094f3c7 100644 --- a/test/test.html +++ b/test/test.html @@ -35,13 +35,32 @@ -
-

4

- +
+
+

3.1

+
    +
  • 4.1
  • +
  • 4.2
  • +
  • 4.3
  • +
+
+ +
+

3.2

+
    +
  • 4.1
  • +
  • 4.2
  • +
+
+ +
+

3.3

+
    +
  • 3.3.1
  • +
  • 3.3.2
  • +
  • 3.3.3
  • +
+
diff --git a/test/test.js b/test/test.js index 5974e3e..f01eb49 100644 --- a/test/test.js +++ b/test/test.js @@ -5,6 +5,7 @@ // 1 // 2 - Three sub-slides // 3 - Three fragment elements +// 3 - Two fragments with same data-fragment-index // 4 @@ -128,7 +129,7 @@ Reveal.addEventListener( 'ready', function() { test( 'Reveal.next', function() { Reveal.slide( 0, 0 ); - // Step through the vertical child slides + // Step through vertical child slides Reveal.next(); deepEqual( Reveal.getIndices(), { h: 1, v: 0, f: undefined } ); @@ -138,7 +139,7 @@ Reveal.addEventListener( 'ready', function() { Reveal.next(); deepEqual( Reveal.getIndices(), { h: 1, v: 2, f: undefined } ); - // There's fragments on this slide + // Step through fragments Reveal.next(); deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: -1 } ); @@ -150,11 +151,15 @@ Reveal.addEventListener( 'ready', function() { Reveal.next(); deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 } ); + }); + + test( 'Reveal.next at end', function() { + Reveal.slide( 3 ); + // We're at the end, this should have no effect Reveal.next(); deepEqual( Reveal.getIndices(), { h: 3, v: 0, f: undefined } ); - // We're at the end, this should have no effect Reveal.next(); deepEqual( Reveal.getIndices(), { h: 3, v: 0, f: undefined } ); }); @@ -180,17 +185,17 @@ Reveal.addEventListener( 'ready', function() { }); test( 'Hiding all fragments', function() { - var fragmentSlide = document.querySelector( '.reveal .slides>section:nth-child(3)' ); + var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' ); Reveal.slide( 2, 0, 0 ); strictEqual( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 1, 'one fragment visible when index is 0' ); Reveal.slide( 2, 0, -1 ); - strictEqual( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 0, 'no fragments visible when index 0' ); + strictEqual( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 0, 'no fragments visible when index is -1' ); }); test( 'Current fragment', function() { - var fragmentSlide = document.querySelector( '.reveal .slides>section:nth-child(3)' ); + var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' ); Reveal.slide( 2, 0 ); strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 0, 'no current fragment at index -1' ); @@ -224,17 +229,17 @@ Reveal.addEventListener( 'ready', function() { // backwards: Reveal.prev(); - deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'prev() goes to prev fragment' ); + deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 }, 'prev() goes to prev fragment' ); Reveal.left(); - deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'left() goes to prev fragment' ); + deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'left() goes to prev fragment' ); Reveal.up(); - deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: -1 }, 'up() goes to prev fragment' ); + deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'up() goes to prev fragment' ); }); test( 'Stepping past fragments', function() { - var fragmentSlide = document.querySelector( '.reveal .slides>section:nth-child(3)' ); + var fragmentSlide = document.querySelector( '#fragment-slides>section:first-child' ); Reveal.slide( 0, 0, 0 ); equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 0, 'no fragments visible when on previous slide' ); @@ -243,6 +248,13 @@ Reveal.addEventListener( 'ready', function() { equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 3, 'all fragments visible when on future slide' ); }); + 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' ); + }); + asyncTest( 'fragmentshown event', function() { expect( 2 ); -- cgit v1.2.3