diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/examples/barebones.html | 1 | ||||
-rw-r--r-- | test/examples/slide-backgrounds.html | 23 | ||||
-rw-r--r-- | test/test-markdown-element-attributes.html | 134 | ||||
-rw-r--r-- | test/test-markdown-element-attributes.js | 46 | ||||
-rw-r--r-- | test/test-markdown-slide-attributes.html | 128 | ||||
-rw-r--r-- | test/test-markdown-slide-attributes.js | 47 | ||||
-rw-r--r-- | test/test.html | 33 | ||||
-rw-r--r-- | test/test.js | 105 |
8 files changed, 498 insertions, 19 deletions
diff --git a/test/examples/barebones.html b/test/examples/barebones.html index 5c03ff3..c948d00 100644 --- a/test/examples/barebones.html +++ b/test/examples/barebones.html @@ -29,7 +29,6 @@ </div> - <script src="../../lib/js/head.min.js"></script> <script src="../../js/reveal.min.js"></script> <script> 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-markdown-element-attributes.html b/test/test-markdown-element-attributes.html new file mode 100644 index 0000000..b638082 --- /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-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$" 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 + +  + <!-- {_class="reveal stretch"} --> + + </script> + </section> + + + + <section data-markdown data-separator="^\n\n\n" + data-vertical="^\n\n" + data-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-markdown-element-attributes.js b/test/test-markdown-element-attributes.js new file mode 100644 index 0000000..4541077 --- /dev/null +++ b/test/test-markdown-element-attributes.js @@ -0,0 +1,46 @@ + + +Reveal.addEventListener( 'ready', function() { + + QUnit.module( 'Markdown' ); + + test( 'Vertical separator', function() { + strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 4, 'found four slides' ); + }); + + + 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 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 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 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 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 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..3b91784 --- /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-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-vertical="^\n\n" + data-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-vertical="^\n\n" + data-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.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..f620b5b 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 @@ -128,7 +145,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 +155,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 +167,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 +187,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 +200,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 +251,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() { |