summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/examples/slide-backgrounds.html23
-rw-r--r--test/test-element-attributes-markdown.html82
-rw-r--r--test/test-markdown-element-attributes.html134
-rw-r--r--test/test-markdown-element-attributes.js (renamed from test/test-element-attributes-markdown.js)22
-rw-r--r--test/test-markdown-slide-attributes.html128
-rw-r--r--test/test-markdown-slide-attributes.js47
-rw-r--r--test/test-markdown.html4
-rw-r--r--test/test.html33
-rw-r--r--test/test.js183
9 files changed, 547 insertions, 109 deletions
diff --git a/test/examples/slide-backgrounds.html b/test/examples/slide-backgrounds.html
index 1e2da16..4f0fe62 100644
--- a/test/examples/slide-backgrounds.html
+++ b/test/examples/slide-backgrounds.html
@@ -75,6 +75,27 @@
<h2>Same background twice (2/2)</h2>
</section>
+ <section>
+ <section data-background="#417203">
+ <h2>Same background twice vertical (1/2)</h2>
+ </section>
+ <section data-background="#417203">
+ <h2>Same background twice vertical (2/2)</h2>
+ </section>
+ </section>
+
+ <section data-background="#934f4d">
+ <h2>Same background from horizontal to vertical (1/3)</h2>
+ </section>
+ <section>
+ <section data-background="#934f4d">
+ <h2>Same background from horizontal to vertical (2/3)</h2>
+ </section>
+ <section data-background="#934f4d">
+ <h2>Same background from horizontal to vertical (3/3)</h2>
+ </section>
+ </section>
+
</div>
</div>
@@ -92,7 +113,7 @@
transition: 'linear',
// transitionSpeed: 'slow',
- // backgroundTransition: 'linear'
+ // backgroundTransition: 'slide'
});
</script>
diff --git a/test/test-element-attributes-markdown.html b/test/test-element-attributes-markdown.html
deleted file mode 100644
index b7ab054..0000000
--- a/test/test-element-attributes-markdown.html
+++ /dev/null
@@ -1,82 +0,0 @@
-<!doctype html>
-<html lang="en">
-
- <head>
- <meta charset="utf-8">
-
- <title>reveal.js - Test Markdown</title>
-
- <link rel="stylesheet" href="../css/reveal.min.css">
- <link rel="stylesheet" href="qunit-1.12.0.css">
- </head>
-
- <body style="overflow: auto;">
-
- <div id="qunit"></div>
- <div id="qunit-fixture"></div>
-
- <div class="reveal" style="display: none;">
-
- <div class="slides">
-
- <!-- <section data-markdown="example.md" data-separator="^\n\n\n" data-vertical="^\n\n"></section> -->
-
- <!-- Slides are separated by newline + three dashes + newline, vertical slides identical but two dashes -->
- <section data-markdown data-separator="^\n---\n$" data-vertical="^\n--\n$">
- <script type="text/template">
- ## Slide 1.1 {_class="fragment fade-out" data-fragment-index="1"}
-
- --
-
- ## Slide 1.2 {_class="fragment shrink"}
-
- Paragraph 1 {_class="fragment grow"}
-
- Paragraph 2 {_class="fragment grow"}
-
- - list item 1 {_class="fragment roll-in"}
- - list item 2 {_class="fragment roll-in"}
- - list item 3 {_class="fragment roll-in"}
-
-
- ---
-
- ## Slide 2
-
-
- Paragraph 1.2
- multi-line {_class="fragment highlight-red"}
-
- Paragraph 2.2 {_class="fragment highlight-red"}
-
- Paragraph 2.3 {_class="fragment highlight-red"}
-
- Paragraph 2.4 {_class="fragment highlight-red"}
-
- - list item 1 {_class="fragment highlight-green"}
- - list item 2 {_class="fragment highlight-green"}
- - list item 3 {_class="fragment highlight-green"}
- - list item 4 {_class="fragment highlight-green"}
- - list item 5 {_class="fragment highlight-green"}
-
- Test
-
- ![Example Picture{_class="reveal stretch"}](assets/image2.png)
-
- </script>
- </section>
-
- </div>
-
- </div>
-
- <script src="../lib/js/head.min.js"></script>
- <script src="../js/reveal.min.js"></script>
- <script src="../plugin/markdown/marked.js"></script>
- <script src="../plugin/markdown/markdown.js"></script>
- <script src="qunit-1.12.0.js"></script>
-
- <script src="test-element-attributes-markdown.js"></script>
-
- </body>
-</html>
diff --git a/test/test-markdown-element-attributes.html b/test/test-markdown-element-attributes.html
new file mode 100644
index 0000000..27b888c
--- /dev/null
+++ b/test/test-markdown-element-attributes.html
@@ -0,0 +1,134 @@
+<!doctype html>
+<html lang="en">
+
+ <head>
+ <meta charset="utf-8">
+
+ <title>reveal.js - Test Markdown Element Attributes</title>
+
+ <link rel="stylesheet" href="../css/reveal.min.css">
+ <link rel="stylesheet" href="qunit-1.12.0.css">
+ </head>
+
+ <body style="overflow: auto;">
+
+ <div id="qunit"></div>
+ <div id="qunit-fixture"></div>
+
+ <div class="reveal" style="display: none;">
+
+ <div class="slides">
+
+ <!-- <section data-markdown="example.md" data-separator="^\n\n\n" data-separator-vertical="^\n\n"></section> -->
+
+ <!-- Slides are separated by newline + three dashes + newline, vertical slides identical but two dashes -->
+ <section data-markdown data-separator="^\n---\n$" data-separator-vertical="^\n--\n$" data-element-attributes="{_\s*?([^}]+?)}">>
+ <script type="text/template">
+ ## Slide 1.1
+ <!-- {_class="fragment fade-out" data-fragment-index="1"} -->
+
+ --
+
+ ## Slide 1.2
+ <!-- {_class="fragment shrink"} -->
+
+ Paragraph 1
+ <!-- {_class="fragment grow"} -->
+
+ Paragraph 2
+ <!-- {_class="fragment grow"} -->
+
+ - list item 1 <!-- {_class="fragment roll-in"} -->
+ - list item 2 <!-- {_class="fragment roll-in"} -->
+ - list item 3 <!-- {_class="fragment roll-in"} -->
+
+
+ ---
+
+ ## Slide 2
+
+
+ Paragraph 1.2
+ multi-line <!-- {_class="fragment highlight-red"} -->
+
+ Paragraph 2.2 <!-- {_class="fragment highlight-red"} -->
+
+ Paragraph 2.3 <!-- {_class="fragment highlight-red"} -->
+
+ Paragraph 2.4 <!-- {_class="fragment highlight-red"} -->
+
+ - list item 1 <!-- {_class="fragment highlight-green"} -->
+ - list item 2<!-- {_class="fragment highlight-green"} -->
+ - list item 3<!-- {_class="fragment highlight-green"} -->
+ - list item 4
+ <!-- {_class="fragment highlight-green"} -->
+ - list item 5<!-- {_class="fragment highlight-green"} -->
+
+ Test
+
+ ![Example Picture](examples/assets/image2.png)
+ <!-- {_class="reveal stretch"} -->
+
+ </script>
+ </section>
+
+
+
+ <section data-markdown data-separator="^\n\n\n"
+ data-separator-vertical="^\n\n"
+ data-separator-notes="^Note:"
+ data-charset="utf-8">
+ <script type="text/template">
+ # Test attributes in Markdown with default separator
+ ## Slide 1 Def <!-- .element: class="fragment highlight-red" data-fragment-index="1" -->
+
+
+ ## Slide 2 Def
+ <!-- .element: class="fragment highlight-red" -->
+
+ </script>
+ </section>
+
+ <section data-markdown>
+ <script type="text/template">
+ ## Hello world
+ A paragraph
+ <!-- .element: class="fragment highlight-blue" -->
+ </script>
+ </section>
+
+ <section data-markdown>
+ <script type="text/template">
+ ## Hello world
+
+ Multiple
+ Line
+ <!-- .element: class="fragment highlight-blue" -->
+ </script>
+ </section>
+
+ <section data-markdown>
+ <script type="text/template">
+ ## Hello world
+
+ Test<!-- .element: class="fragment highlight-blue" -->
+
+ More Test
+ </script>
+ </section>
+
+
+ </div>
+
+ </div>
+
+ <script src="../lib/js/head.min.js"></script>
+ <script src="../js/reveal.min.js"></script>
+ <script src="../plugin/markdown/marked.js"></script>
+ <script src="../plugin/markdown/markdown.js"></script>
+ <script src="qunit-1.12.0.js"></script>
+
+ <script src="test-markdown-element-attributes.js"></script>
+
+ </body>
+</html>
diff --git a/test/test-element-attributes-markdown.js b/test/test-markdown-element-attributes.js
index e79806c..4541077 100644
--- a/test/test-element-attributes-markdown.js
+++ b/test/test-markdown-element-attributes.js
@@ -5,33 +5,41 @@ Reveal.addEventListener( 'ready', function() {
QUnit.module( 'Markdown' );
test( 'Vertical separator', function() {
- strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 2, 'found two slides' );
+ strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 4, 'found four slides' );
});
- test( 'Attributes on vertical slides header', function() {
+ test( 'Attributes on element header in vertical slides', function() {
strictEqual( document.querySelectorAll( '.reveal .slides section>section h2.fragment.fade-out' ).length, 1, 'found one vertical slide with class fragment.fade-out on header' );
strictEqual( document.querySelectorAll( '.reveal .slides section>section h2.fragment.shrink' ).length, 1, 'found one vertical slide with class fragment.shrink on header' );
});
- test( 'Attributes on vertical slides paragraphs', function() {
+ test( 'Attributes on element paragraphs in vertical slides', function() {
strictEqual( document.querySelectorAll( '.reveal .slides section>section p.fragment.grow' ).length, 2, 'found a vertical slide with two paragraphs with class fragment.grow' );
});
- test( 'Attributes on vertical slides list items', function() {
+ test( 'Attributes on element list items in vertical slides', function() {
strictEqual( document.querySelectorAll( '.reveal .slides section>section li.fragment.roll-in' ).length, 3, 'found a vertical slide with three list items with class fragment.roll-in' );
});
- test( 'Attributes on horizontal slides paragraphs', function() {
+ test( 'Attributes on element paragraphs in horizontal slides', function() {
strictEqual( document.querySelectorAll( '.reveal .slides section p.fragment.highlight-red' ).length, 4, 'found a horizontal slide with four paragraphs with class fragment.grow' );
});
- test( 'Attributes on horizontal slides list items', function() {
+ test( 'Attributes on element list items in horizontal slides', function() {
strictEqual( document.querySelectorAll( '.reveal .slides section li.fragment.highlight-green' ).length, 5, 'found a horizontal slide with five list items with class fragment.roll-in' );
});
- test( 'Attributes on horizontal slides list items', function() {
+ test( 'Attributes on element list items in horizontal slides', function() {
strictEqual( document.querySelectorAll( '.reveal .slides section img.reveal.stretch' ).length, 1, 'found a horizontal slide with stretched image, class img.reveal.stretch' );
});
+ test( 'Attributes on elements in vertical slides with default element attribute separator', function() {
+ strictEqual( document.querySelectorAll( '.reveal .slides section h2.fragment.highlight-red' ).length, 2, 'found two h2 titles with fragment highlight-red in vertical slides with default element attribute separator' );
+ });
+
+ test( 'Attributes on elements in single slides with default element attribute separator', function() {
+ strictEqual( document.querySelectorAll( '.reveal .slides section p.fragment.highlight-blue' ).length, 3, 'found three elements with fragment highlight-blue in single slide with default element attribute separator' );
+ });
+
} );
Reveal.initialize();
diff --git a/test/test-markdown-slide-attributes.html b/test/test-markdown-slide-attributes.html
new file mode 100644
index 0000000..bd7b28f
--- /dev/null
+++ b/test/test-markdown-slide-attributes.html
@@ -0,0 +1,128 @@
+<!doctype html>
+<html lang="en">
+
+ <head>
+ <meta charset="utf-8">
+
+ <title>reveal.js - Test Markdown Attributes</title>
+
+ <link rel="stylesheet" href="../css/reveal.min.css">
+ <link rel="stylesheet" href="qunit-1.12.0.css">
+ </head>
+
+ <body style="overflow: auto;">
+
+ <div id="qunit"></div>
+ <div id="qunit-fixture"></div>
+
+ <div class="reveal" style="display: none;">
+
+ <div class="slides">
+
+ <!-- <section data-markdown="example.md" data-separator="^\n\n\n" data-separator-vertical="^\n\n"></section> -->
+
+ <!-- Slides are separated by three lines, vertical slides by two lines, attributes are one any line starting with (spaces and) two dashes -->
+ <section data-markdown data-separator="^\n\n\n"
+ data-separator-vertical="^\n\n"
+ data-separator-notes="^Note:"
+ data-attributes="--\s(.*?)$"
+ data-charset="utf-8">
+ <script type="text/template">
+ # Test attributes in Markdown
+ ## Slide 1
+
+
+
+ ## Slide 2
+ <!-- -- id="slide2" data-transition="zoom" data-background="#A0C66B" -->
+
+
+ ## Slide 2.1
+ <!-- -- data-background="#ff0000" data-transition="fade" -->
+
+
+ ## Slide 2.2
+ [Link to Slide2](#/slide2)
+
+
+
+ ## Slide 3
+ <!-- -- data-transition="zoom" data-background="#C6916B" -->
+
+
+
+ ## Slide 4
+ </script>
+ </section>
+
+ <section data-markdown data-separator="^\n\n\n"
+ data-separator-vertical="^\n\n"
+ data-separator-notes="^Note:"
+ data-charset="utf-8">
+ <script type="text/template">
+ # Test attributes in Markdown with default separator
+ ## Slide 1 Def
+
+
+
+ ## Slide 2 Def
+ <!-- .slide: id="slide2def" data-transition="concave" data-background="#A7C66B" -->
+
+
+ ## Slide 2.1 Def
+ <!-- .slide: data-background="#f70000" data-transition="page" -->
+
+
+ ## Slide 2.2 Def
+ [Link to Slide2](#/slide2def)
+
+
+
+ ## Slide 3 Def
+ <!-- .slide: data-transition="concave" data-background="#C7916B" -->
+
+
+
+ ## Slide 4
+ </script>
+ </section>
+
+ <section data-markdown>
+ <script type="text/template">
+ <!-- .slide: data-background="#ff0000" -->
+ ## Hello world
+ </script>
+ </section>
+
+ <section data-markdown>
+ <script type="text/template">
+ ## Hello world
+ <!-- .slide: data-background="#ff0000" -->
+ </script>
+ </section>
+
+ <section data-markdown>
+ <script type="text/template">
+ ## Hello world
+
+ Test
+ <!-- .slide: data-background="#ff0000" -->
+
+ More Test
+ </script>
+ </section>
+
+ </div>
+
+ </div>
+
+ <script src="../lib/js/head.min.js"></script>
+ <script src="../js/reveal.min.js"></script>
+ <script src="../plugin/markdown/marked.js"></script>
+ <script src="../plugin/markdown/markdown.js"></script>
+ <script src="qunit-1.12.0.js"></script>
+
+ <script src="test-markdown-slide-attributes.js"></script>
+
+ </body>
+</html>
diff --git a/test/test-markdown-slide-attributes.js b/test/test-markdown-slide-attributes.js
new file mode 100644
index 0000000..3817fd3
--- /dev/null
+++ b/test/test-markdown-slide-attributes.js
@@ -0,0 +1,47 @@
+
+
+Reveal.addEventListener( 'ready', function() {
+
+ QUnit.module( 'Markdown' );
+
+ test( 'Vertical separator', function() {
+ strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 6, 'found six vertical slides' );
+ });
+
+ test( 'Id on slide', function() {
+ strictEqual( document.querySelectorAll( '.reveal .slides>section>section#slide2' ).length, 1, 'found one slide with id slide2' );
+ strictEqual( document.querySelectorAll( '.reveal .slides>section>section a[href="#/slide2"]' ).length, 1, 'found one slide with a link to slide2' );
+ });
+
+ test( 'data-background attributes', function() {
+ strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#A0C66B"]' ).length, 1, 'found one vertical slide with data-background="#A0C66B"' );
+ strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#ff0000"]' ).length, 1, 'found one vertical slide with data-background="#ff0000"' );
+ strictEqual( document.querySelectorAll( '.reveal .slides>section[data-background="#C6916B"]' ).length, 1, 'found one slide with data-background="#C6916B"' );
+ });
+
+ test( 'data-transition attributes', function() {
+ strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="zoom"]' ).length, 1, 'found one vertical slide with data-transition="zoom"' );
+ strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="fade"]' ).length, 1, 'found one vertical slide with data-transition="fade"' );
+ strictEqual( document.querySelectorAll( '.reveal .slides section [data-transition="zoom"]' ).length, 1, 'found one slide with data-transition="zoom"' );
+ });
+
+ test( 'data-background attributes with default separator', function() {
+ strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#A7C66B"]' ).length, 1, 'found one vertical slide with data-background="#A0C66B"' );
+ strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#f70000"]' ).length, 1, 'found one vertical slide with data-background="#ff0000"' );
+ strictEqual( document.querySelectorAll( '.reveal .slides>section[data-background="#C7916B"]' ).length, 1, 'found one slide with data-background="#C6916B"' );
+ });
+
+ test( 'data-transition attributes with default separator', function() {
+ strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="concave"]' ).length, 1, 'found one vertical slide with data-transition="zoom"' );
+ strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="page"]' ).length, 1, 'found one vertical slide with data-transition="fade"' );
+ strictEqual( document.querySelectorAll( '.reveal .slides section [data-transition="concave"]' ).length, 1, 'found one slide with data-transition="zoom"' );
+ });
+
+ test( 'data-transition attributes with inline content', function() {
+ strictEqual( document.querySelectorAll( '.reveal .slides>section[data-background="#ff0000"]' ).length, 3, 'found three horizontal slides with data-background="#ff0000"' );
+ });
+
+} );
+
+Reveal.initialize();
+
diff --git a/test/test-markdown.html b/test/test-markdown.html
index c89af30..901b2de 100644
--- a/test/test-markdown.html
+++ b/test/test-markdown.html
@@ -19,10 +19,10 @@
<div class="slides">
- <!-- <section data-markdown="example.md" data-separator="^\n\n\n" data-vertical="^\n\n"></section> -->
+ <!-- <section data-markdown="example.md" data-separator="^\n\n\n" data-separator-vertical="^\n\n"></section> -->
<!-- Slides are separated by newline + three dashes + newline, vertical slides identical but two dashes -->
- <section data-markdown data-separator="^\n---\n$" data-vertical="^\n--\n$">
+ <section data-markdown data-separator="^\n---\n$" data-separator-vertical="^\n--\n$">
<script type="text/template">
## Slide 1.1
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 @@
</section>
</section>
- <section>
- <h1>4</h1>
- <ul>
- <li class="fragment">4.1</li>
- <li class="fragment">4.2</li>
- <li class="fragment">4.3</li>
- </ul>
+ <section id="fragment-slides">
+ <section>
+ <h1>3.1</h1>
+ <ul>
+ <li class="fragment">4.1</li>
+ <li class="fragment">4.2</li>
+ <li class="fragment">4.3</li>
+ </ul>
+ </section>
+
+ <section>
+ <h1>3.2</h1>
+ <ul>
+ <li class="fragment" data-fragment-index="0">4.1</li>
+ <li class="fragment" data-fragment-index="0">4.2</li>
+ </ul>
+ </section>
+
+ <section>
+ <h1>3.3</h1>
+ <ul>
+ <li class="fragment" data-fragment-index="1">3.3.1</li>
+ <li class="fragment" data-fragment-index="4">3.3.2</li>
+ <li class="fragment" data-fragment-index="4">3.3.3</li>
+ </ul>
+ </section>
</section>
<section>
diff --git a/test/test.js b/test/test.js
index 00c9622..90a002a 100644
--- a/test/test.js
+++ b/test/test.js
@@ -5,11 +5,28 @@
// 1
// 2 - Three sub-slides
// 3 - Three fragment elements
+// 3 - Two fragments with same data-fragment-index
// 4
Reveal.addEventListener( 'ready', function() {
+ // ---------------------------------------------------------------
+ // 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' );
+ });
// ---------------------------------------------------------------
// API TESTS
@@ -64,6 +81,10 @@ Reveal.addEventListener( 'ready', function() {
strictEqual( Reveal.isLastSlide(), false, 'false after Reveal.slide( 0, 0 )' );
});
+ test( 'Reveal.getTotalSlides', function() {
+ strictEqual( Reveal.getTotalSlides(), 8, 'eight slides in total' );
+ });
+
test( 'Reveal.getIndices', function() {
var indices = Reveal.getIndices();
@@ -99,6 +120,16 @@ Reveal.addEventListener( 'ready', function() {
equal( Reveal.getCurrentSlide(), secondSlide, 'current is slide #1' );
});
+ 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' );
+ });
+
test( 'Reveal.getScale', function() {
ok( typeof Reveal.getScale() === 'number', 'has scale' );
});
@@ -128,7 +159,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 +169,10 @@ 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 } );
+
Reveal.next();
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 } );
@@ -147,14 +181,15 @@ Reveal.addEventListener( 'ready', function() {
Reveal.next();
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 } );
+ });
- Reveal.next();
- deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 3 } );
+ 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 } );
});
@@ -166,6 +201,9 @@ Reveal.addEventListener( 'ready', function() {
QUnit.module( 'Fragments' );
test( 'Sliding to fragments', function() {
+ Reveal.slide( 2, 0, -1 );
+ deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: -1 }, 'Reveal.slide( 2, 0, -1 )' );
+
Reveal.slide( 2, 0, 0 );
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'Reveal.slide( 2, 0, 0 )' );
@@ -176,19 +214,45 @@ Reveal.addEventListener( 'ready', function() {
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'Reveal.slide( 2, 0, 1 )' );
});
- test( 'Stepping through fragments', function() {
+ test( 'Hiding all fragments', function() {
+ 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 is -1' );
+ });
+
+ test( 'Current fragment', function() {
+ 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' );
+
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' );
+ });
+
+ test( 'Stepping through fragments', function() {
+ Reveal.slide( 2, 0, -1 );
// forwards:
Reveal.next();
- deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'next() goes to next fragment' );
+ deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'next() goes to next fragment' );
Reveal.right();
- deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 }, 'right() goes to next fragment' );
+ deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'right() goes to next fragment' );
Reveal.down();
- deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 3 }, 'down() goes to next fragment' );
+ deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 }, 'down() goes to next fragment' );
Reveal.down(); // moves to f #3
@@ -201,7 +265,42 @@ Reveal.addEventListener( 'ready', function() {
deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'left() goes to prev fragment' );
Reveal.up();
- deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'left() 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( '#fragment-slides>section:nth-child(1)' );
+
+ 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' );
+ });
+
+ 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' );
+ });
+
+ 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' );
});
asyncTest( 'fragmentshown event', function() {
@@ -247,6 +346,70 @@ Reveal.addEventListener( 'ready', function() {
// ---------------------------------------------------------------
+ // 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 );
+ });
+
+
+ // ---------------------------------------------------------------
// CONFIGURATION VALUES
QUnit.module( 'Configuration' );