Skip to content

Commit 0fcff33

Browse files
committed
additional fragment tests
1 parent 0fb343f commit 0fcff33

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

test/test.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ Reveal.addEventListener( 'ready', function() {
239239
});
240240

241241
test( 'Stepping past fragments', function() {
242-
var fragmentSlide = document.querySelector( '#fragment-slides>section:first-child' );
242+
var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' );
243243

244244
Reveal.slide( 0, 0, 0 );
245245
equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 0, 'no fragments visible when on previous slide' );
@@ -255,6 +255,24 @@ Reveal.addEventListener( 'ready', function() {
255255
equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 2, 'both fragments of same index are shown' );
256256
});
257257

258+
test( 'Index generation', function() {
259+
var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' );
260+
261+
// These have no indices defined to start with
262+
equal( fragmentSlide.querySelectorAll( '.fragment' )[0].getAttribute( 'data-fragment-index' ), '0' );
263+
equal( fragmentSlide.querySelectorAll( '.fragment' )[1].getAttribute( 'data-fragment-index' ), '1' );
264+
equal( fragmentSlide.querySelectorAll( '.fragment' )[2].getAttribute( 'data-fragment-index' ), '2' );
265+
});
266+
267+
test( 'Index normalization', function() {
268+
var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(3)' );
269+
270+
// These start out as 1-4-4 and should normalize to 0-1-1
271+
equal( fragmentSlide.querySelectorAll( '.fragment' )[0].getAttribute( 'data-fragment-index' ), '0' );
272+
equal( fragmentSlide.querySelectorAll( '.fragment' )[1].getAttribute( 'data-fragment-index' ), '1' );
273+
equal( fragmentSlide.querySelectorAll( '.fragment' )[2].getAttribute( 'data-fragment-index' ), '1' );
274+
});
275+
258276
asyncTest( 'fragmentshown event', function() {
259277
expect( 2 );
260278

0 commit comments

Comments
 (0)