diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/assets/external-script-a.js | 1 | ||||
-rw-r--r-- | test/assets/external-script-b.js | 1 | ||||
-rw-r--r-- | test/assets/external-script-c.js | 1 | ||||
-rw-r--r-- | test/assets/external-script-d.js | 1 | ||||
-rw-r--r-- | test/examples/assets/beeping.txt | 2 | ||||
-rw-r--r-- | test/examples/assets/beeping.wav | bin | 0 -> 422472 bytes | |||
-rw-r--r-- | test/examples/embedded-media.html | 6 | ||||
-rw-r--r-- | test/examples/math.html | 26 | ||||
-rw-r--r-- | test/examples/slide-backgrounds.html | 1 | ||||
-rw-r--r-- | test/examples/slide-transitions.html | 1 | ||||
-rw-r--r-- | test/test-dependencies-async.html | 78 | ||||
-rw-r--r-- | test/test-dependencies.html | 54 | ||||
-rw-r--r-- | test/test-grid-navigation.html | 74 | ||||
-rw-r--r-- | test/test-markdown-element-attributes.html | 4 | ||||
-rw-r--r-- | test/test-markdown-external.html | 9 | ||||
-rw-r--r-- | test/test-markdown-options.html | 1 | ||||
-rw-r--r-- | test/test-markdown-slide-attributes.html | 1 | ||||
-rw-r--r-- | test/test-markdown.html | 1 | ||||
-rw-r--r-- | test/test-pdf.html | 3 | ||||
-rw-r--r-- | test/test-plugins.html | 92 | ||||
-rw-r--r-- | test/test-state.html | 139 | ||||
-rw-r--r-- | test/test.html | 7 | ||||
-rw-r--r-- | test/test.js | 5 |
23 files changed, 486 insertions, 22 deletions
diff --git a/test/assets/external-script-a.js b/test/assets/external-script-a.js new file mode 100644 index 0000000..cbc8da1 --- /dev/null +++ b/test/assets/external-script-a.js @@ -0,0 +1 @@ +window.externalScriptSequence += 'A';
\ No newline at end of file diff --git a/test/assets/external-script-b.js b/test/assets/external-script-b.js new file mode 100644 index 0000000..e5bca5a --- /dev/null +++ b/test/assets/external-script-b.js @@ -0,0 +1 @@ +window.externalScriptSequence += 'B';
\ No newline at end of file diff --git a/test/assets/external-script-c.js b/test/assets/external-script-c.js new file mode 100644 index 0000000..7d4ccf6 --- /dev/null +++ b/test/assets/external-script-c.js @@ -0,0 +1 @@ +window.externalScriptSequence += 'C';
\ No newline at end of file diff --git a/test/assets/external-script-d.js b/test/assets/external-script-d.js new file mode 100644 index 0000000..1c5925b --- /dev/null +++ b/test/assets/external-script-d.js @@ -0,0 +1 @@ +window.externalScriptSequence += 'D';
\ No newline at end of file diff --git a/test/examples/assets/beeping.txt b/test/examples/assets/beeping.txt new file mode 100644 index 0000000..bf41997 --- /dev/null +++ b/test/examples/assets/beeping.txt @@ -0,0 +1,2 @@ +Source: https://freesound.org/people/fennelliott/sounds/379419/ +License: CC0 (public domain)
\ No newline at end of file diff --git a/test/examples/assets/beeping.wav b/test/examples/assets/beeping.wav Binary files differnew file mode 100644 index 0000000..38747a5 --- /dev/null +++ b/test/examples/assets/beeping.wav diff --git a/test/examples/embedded-media.html b/test/examples/embedded-media.html index bbad4be..91457e4 100644 --- a/test/examples/embedded-media.html +++ b/test/examples/embedded-media.html @@ -30,11 +30,15 @@ <h2>Empty Slide</h2> </section> + <section> + <h2>Auto-playing audio</h2> + <audio src="assets/beeping.wav" data-autoplay></audio> + </section> + </div> </div> - <script src="../../lib/js/head.min.js"></script> <script src="../../js/reveal.js"></script> <script> diff --git a/test/examples/math.html b/test/examples/math.html index d35e827..0f74a8f 100644 --- a/test/examples/math.html +++ b/test/examples/math.html @@ -83,6 +83,14 @@ </section> <section> + <h3>TeX Macros</h3> + + Here is a common vector space: + \[L^2(\R) = \set{u : \R \to \R}{\int_\R |u|^2 < +\infty}\] + used in functional analysis. + </section> + + <section> <section> <h3>The Lorenz Equations</h3> @@ -153,13 +161,20 @@ \] </div> </section> + + <section> + <h3>TeX Macros</h3> + + Here is a common vector space: + \[L^2(\R) = \set{u : \R \to \R}{\int_\R |u|^2 < +\infty}\] + used in functional analysis. + </section> </section> </div> </div> - <script src="../../lib/js/head.min.js"></script> <script src="../../js/reveal.js"></script> <script> @@ -170,11 +185,16 @@ math: { // mathjax: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js', - config: 'TeX-AMS_HTML-full' + config: 'TeX-AMS_HTML-full', + TeX: { + Macros: { + R: '\\mathbb{R}', + set: [ '\\left\\{#1 \\; ; \\; #2\\right\\}', 2 ] + } + } }, dependencies: [ - { src: '../../lib/js/classList.js' }, { src: '../../plugin/math/math.js', async: true } ] }); diff --git a/test/examples/slide-backgrounds.html b/test/examples/slide-backgrounds.html index 316c92a..e08d260 100644 --- a/test/examples/slide-backgrounds.html +++ b/test/examples/slide-backgrounds.html @@ -122,7 +122,6 @@ </div> - <script src="../../lib/js/head.min.js"></script> <script src="../../js/reveal.js"></script> <script> diff --git a/test/examples/slide-transitions.html b/test/examples/slide-transitions.html index 88119dc..b7520ab 100644 --- a/test/examples/slide-transitions.html +++ b/test/examples/slide-transitions.html @@ -81,7 +81,6 @@ </div> - <script src="../../lib/js/head.min.js"></script> <script src="../../js/reveal.js"></script> <script> diff --git a/test/test-dependencies-async.html b/test/test-dependencies-async.html new file mode 100644 index 0000000..b36c31b --- /dev/null +++ b/test/test-dependencies-async.html @@ -0,0 +1,78 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test Async Dependencies</title> + + <link rel="stylesheet" href="../css/reveal.css"> + <link rel="stylesheet" href="qunit-2.5.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>Slide content</section> + + </div> + + </div> + + <script src="../js/reveal.js"></script> + <script src="qunit-2.5.0.js"></script> + + <script> + var externalScriptSequence = ''; + var scriptCount = 0; + + QUnit.config.autostart = false; + QUnit.module( 'Async Dependencies' ); + + QUnit.test( 'Async scripts are loaded', function( assert ) { + assert.expect( 5 ); + var done = assert.async( 5 ); + + function callback( event ) { + if( externalScriptSequence.length === 1 ) { + assert.ok( externalScriptSequence === 'A', 'first callback was sync script' ); + done(); + } + else { + assert.ok( true, 'async script loaded' ); + done(); + } + + if( externalScriptSequence.length === 4 ) { + assert.ok( externalScriptSequence.indexOf( 'A' ) !== -1 && + externalScriptSequence.indexOf( 'B' ) !== -1 && + externalScriptSequence.indexOf( 'C' ) !== -1 && + externalScriptSequence.indexOf( 'D' ) !== -1, 'four unique scripts were loaded' ); + done(); + } + + scriptCount ++; + } + + Reveal.initialize({ + dependencies: [ + { src: 'assets/external-script-a.js', async: false, callback: callback }, + { src: 'assets/external-script-b.js', async: true, callback: callback }, + { src: 'assets/external-script-c.js', async: true, callback: callback }, + { src: 'assets/external-script-d.js', async: true, callback: callback } + ] + }); + }); + + QUnit.start(); + + </script> + + </body> +</html> diff --git a/test/test-dependencies.html b/test/test-dependencies.html new file mode 100644 index 0000000..49aaf60 --- /dev/null +++ b/test/test-dependencies.html @@ -0,0 +1,54 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test Dependencies</title> + + <link rel="stylesheet" href="../css/reveal.css"> + <link rel="stylesheet" href="qunit-2.5.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>Slide content</section> + + </div> + + </div> + + <script src="../js/reveal.js"></script> + <script src="qunit-2.5.0.js"></script> + + <script> + window.externalScriptSequence = ''; + + Reveal.addEventListener( 'ready', function() { + + QUnit.module( 'Dependencies' ); + + QUnit.test( 'Load synchronous scripts', function( assert ) { + assert.strictEqual( window.externalScriptSequence, 'ABC', 'Loaded and executed in order' ); + }); + + } ); + + Reveal.initialize({ + dependencies: [ + { src: 'assets/external-script-a.js' }, + { src: 'assets/external-script-b.js' }, + { src: 'assets/external-script-c.js' } + ] + }); + </script> + + </body> +</html> diff --git a/test/test-grid-navigation.html b/test/test-grid-navigation.html new file mode 100644 index 0000000..21e7636 --- /dev/null +++ b/test/test-grid-navigation.html @@ -0,0 +1,74 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test Grid</title> + + <link rel="stylesheet" href="../css/reveal.css"> + <link rel="stylesheet" href="qunit-2.5.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>0</section> + <section> + <section>1.1</section> + <section>1.2</section> + <section>1.3</section> + <section>1.4</section> + </section> + <section> + <section>2.1</section> + <section>2.2</section> + <section>2.3</section> + <section>2.4</section> + </section> + + </div> + + </div> + + <script src="../js/reveal.js"></script> + <script src="qunit-2.5.0.js"></script> + + <script> + Reveal.addEventListener( 'ready', function() { + + QUnit.module( 'Grid Navigation' ); + + QUnit.test( 'Disabled', function( assert ) { + Reveal.right(); + Reveal.down(); + Reveal.down(); + assert.deepEqual( Reveal.getIndices(), { h: 1, v: 2, f: undefined }, 'Correct starting point' ); + Reveal.right(); + assert.deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: undefined }, 'Moves to top when going to adjacent stack' ); + }); + + QUnit.test( 'Enabled', function( assert ) { + Reveal.configure({ navigationMode: 'grid' }); + Reveal.slide( 0, 0 ); + Reveal.right(); + Reveal.down(); + Reveal.down(); + assert.deepEqual( Reveal.getIndices(), { h: 1, v: 2, f: undefined }, 'Correct starting point' ); + Reveal.right(); + assert.deepEqual( Reveal.getIndices(), { h: 2, v: 2, f: undefined }, 'Remains at same vertical index when going to adjacent stack' ); + }); + + } ); + + Reveal.initialize(); + </script> + + </body> +</html> diff --git a/test/test-markdown-element-attributes.html b/test/test-markdown-element-attributes.html index 4a09272..741131f 100644 --- a/test/test-markdown-element-attributes.html +++ b/test/test-markdown-element-attributes.html @@ -66,8 +66,7 @@ Test - ![Example Picture](examples/assets/image2.png) - <!-- {_class="reveal stretch"} --> + ![Example Picture](examples/assets/image2.png) <!-- {_class="reveal stretch"} --> </script> </section> @@ -122,7 +121,6 @@ </div> - <script src="../lib/js/head.min.js"></script> <script src="../js/reveal.js"></script> <script src="../plugin/markdown/marked.js"></script> <script src="../plugin/markdown/markdown.js"></script> diff --git a/test/test-markdown-external.html b/test/test-markdown-external.html index d4912b0..93cd983 100644 --- a/test/test-markdown-external.html +++ b/test/test-markdown-external.html @@ -13,24 +13,25 @@ <body style="overflow: auto;"> <div id="qunit"></div> - <div id="qunit-fixture"></div> + <div id="qunit-fixture"></div> <div class="reveal" style="display: none;"> <div class="slides"> - <section data-markdown="simple.md" data-separator="^\r?\n\r?\n\r?\n" data-separator-vertical="^\r?\n\r?\n"></section> + <!-- <section data-markdown="simple.md" data-separator="^\r?\n\r?\n\r?\n" data-separator-vertical="^\r?\n\r?\n"></section> --> </div> </div> - <script src="../lib/js/head.min.js"></script> <script src="../js/reveal.js"></script> <script src="../plugin/highlight/highlight.js"></script> <script src="../plugin/markdown/marked.js"></script> <script src="../plugin/markdown/markdown.js"></script> <script src="qunit-2.5.0.js"></script> - <script src="test-markdown-external.js"></script> + <!-- <script src="test-markdown-external.js"></script> --> + + <!-- Test disabled 28/2/2019 by Hakim – Markdown plugin needs to be updated to load extenal files asycnhronously --> </body> </html> diff --git a/test/test-markdown-options.html b/test/test-markdown-options.html index 598243a..5391a19 100644 --- a/test/test-markdown-options.html +++ b/test/test-markdown-options.html @@ -31,7 +31,6 @@ </div> - <script src="../lib/js/head.min.js"></script> <script src="../js/reveal.js"></script> <script src="qunit-2.5.0.js"></script> diff --git a/test/test-markdown-slide-attributes.html b/test/test-markdown-slide-attributes.html index e90a9cf..ba9e710 100644 --- a/test/test-markdown-slide-attributes.html +++ b/test/test-markdown-slide-attributes.html @@ -116,7 +116,6 @@ </div> - <script src="../lib/js/head.min.js"></script> <script src="../js/reveal.js"></script> <script src="../plugin/markdown/marked.js"></script> <script src="../plugin/markdown/markdown.js"></script> diff --git a/test/test-markdown.html b/test/test-markdown.html index 00f7e7a..e1e5926 100644 --- a/test/test-markdown.html +++ b/test/test-markdown.html @@ -40,7 +40,6 @@ </div> - <script src="../lib/js/head.min.js"></script> <script src="../js/reveal.js"></script> <script src="../plugin/markdown/marked.js"></script> <script src="../plugin/markdown/markdown.js"></script> diff --git a/test/test-pdf.html b/test/test-pdf.html index 5ab8578..a0b8282 100644 --- a/test/test-pdf.html +++ b/test/test-pdf.html @@ -22,7 +22,7 @@ <section> <h1>1</h1> - <img data-src="fake-url.png"> + <img data-src=""> </section> <section> @@ -73,7 +73,6 @@ </div> - <script src="../lib/js/head.min.js"></script> <script src="../js/reveal.js"></script> <script src="qunit-2.5.0.js"></script> diff --git a/test/test-plugins.html b/test/test-plugins.html new file mode 100644 index 0000000..13e3692 --- /dev/null +++ b/test/test-plugins.html @@ -0,0 +1,92 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test Plugins</title> + + <link rel="stylesheet" href="../css/reveal.css"> + <link rel="stylesheet" href="qunit-2.5.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>Slide content</section> + + </div> + + </div> + + <script src="../js/reveal.js"></script> + <script src="qunit-2.5.0.js"></script> + + <script> + + QUnit.module( 'Plugins' ); + + var initCounter = { PluginB: 0, PluginC: 0, PluginD: 0 }; + + // Plugin with no init method + var PluginA = {}; + + // Plugin with init method + var PluginB = { init: function() { + initCounter['PluginB'] += 1; + } }; + + // Async plugin with init method + var PluginC = { init: function() { + return new Promise(function( resolve ) { + setTimeout( () => { + initCounter['PluginC'] += 1; + resolve(); + }, 1000 ); + }); + } }; + + // Plugin initialized after reveal.js is ready + var PluginD = { init: function() { + initCounter['PluginD'] += 1; + } }; + + Reveal.registerPlugin( 'PluginA', PluginA ); + Reveal.registerPlugin( 'PluginB', PluginB ); + Reveal.registerPlugin( 'PluginC', PluginC ); + + Reveal.initialize(); + + QUnit.test( 'Can initialize synchronously', function( assert ) { + assert.strictEqual( initCounter['PluginB'], 1 ); + + Reveal.registerPlugin( 'PluginB', PluginB ); + + assert.strictEqual( initCounter['PluginB'], 1, 'prevents duplicate registration' ); + }); + + QUnit.test( 'Can initialie asynchronously', function( assert ) { + assert.expect( 3 ); + var done = assert.async( 2 ); + + assert.strictEqual( initCounter['PluginC'], 0, 'async plugin not immediately initialized' ); + + Reveal.addEventListener( 'ready', function() { + assert.strictEqual( initCounter['PluginC'], 1, 'finsihed initializing when reveal.js dispatches "ready"' ); + done(); + + Reveal.registerPlugin( 'PluginD', PluginD ); + assert.strictEqual( initCounter['PluginD'], 1, 'plugin registered after reveal.js is ready still initiailizes' ); + done(); + }); + } ); + </script> + + </body> +</html> diff --git a/test/test-state.html b/test/test-state.html new file mode 100644 index 0000000..e6ae423 --- /dev/null +++ b/test/test-state.html @@ -0,0 +1,139 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test State</title> + + <link rel="stylesheet" href="../css/reveal.css"> + <link rel="stylesheet" href="qunit-2.5.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>No state</section> + <section id="slide2" data-state="state1">State 1</section> + <section data-state="state1">State 1</section> + <section data-state="state2">State 2</section> + <section> + <section>No state</section> + <section data-state="state1">State 1</section> + <section data-state="state3">State 3</section> + <section>No state</section> + </section> + <section>No state</section> + + </div> + + </div> + + <script src="../js/reveal.js"></script> + <script src="qunit-2.5.0.js"></script> + + <script> + + + Reveal.addEventListener( 'ready', function() { + + QUnit.module( 'State' ); + + QUnit.test( 'Fire events when changing slide', function( assert ) { + assert.expect( 2 ); + var state1 = assert.async(); + var state2 = assert.async(); + + var _onState1 = function( event ) { + assert.ok( true, 'state1 fired' ); + state1(); + } + + var _onState2 = function( event ) { + assert.ok( true, 'state2 fired' ); + state2(); + } + + Reveal.addEventListener( 'state1', _onState1 ); + Reveal.addEventListener( 'state2', _onState2 ); + + Reveal.slide( 1 ); + Reveal.slide( 3 ); + + Reveal.removeEventListener( 'state1', _onState1 ); + Reveal.removeEventListener( 'state2', _onState2 ); + }); + + QUnit.test( 'Fire state events for vertical slides', function( assert ) { + assert.expect( 2 ); + var done = assert.async( 2 ); + + var _onState1 = function( event ) { + assert.ok( true, 'state1 fired' ); + done(); + } + + var _onState3 = function( event ) { + assert.ok( true, 'state3 fired' ); + done(); + } + + Reveal.addEventListener( 'state1', _onState1 ); + Reveal.addEventListener( 'state3', _onState3 ); + + Reveal.slide( 0 ); + Reveal.slide( 4, 1 ); + Reveal.slide( 4, 2 ); + + Reveal.removeEventListener( 'state1', _onState1 ); + Reveal.removeEventListener( 'state3', _onState3 ); + }); + + QUnit.test( 'No events if state remains unchanged', function( assert ) { + var stateChanges = 0; + + var _onEvent = function( event ) { + stateChanges += 1; + } + + Reveal.addEventListener( 'state1', _onEvent ); + + Reveal.slide( 0 ); // no state + Reveal.slide( 1 ); // state1 + Reveal.slide( 2 ); // state1 + Reveal.prev(); // state1 + Reveal.next(); // state1 + Reveal.slide( 4, 1 ); // state1 + Reveal.slide( 0 ); // no state + + Reveal.removeEventListener( 'state1', _onEvent ); + + assert.strictEqual( stateChanges, 1, 'no event was fired when going to slide with same state' ); + }); + + QUnit.test( 'Event order', function( assert ) { + var _onEvent = function( event ) { + assert.ok( Reveal.getCurrentSlide() == document.querySelector( '#slide2' ), 'correct current slide immediately after state event' ); + } + + Reveal.addEventListener( 'state1', _onEvent ); + + Reveal.slide( 0 ); + Reveal.slide( 1 ); + + Reveal.removeEventListener( 'state1', _onEvent ); + }); + + } ); + + Reveal.initialize(); + </script> + + </body> +</html> diff --git a/test/test.html b/test/test.html index f0a5050..309b201 100644 --- a/test/test.html +++ b/test/test.html @@ -21,9 +21,9 @@ <section data-background-image="examples/assets/image1.png"> <h1>1</h1> - <img data-src="fake-url.png"> - <video data-src="fake-url.mp4"></video> - <audio data-src="fake-url.mp3"></audio> + <img data-src=""> + <video data-src=""></video> + <audio data-src=""></audio> <aside class="notes">speaker notes 1</aside> </section> @@ -76,7 +76,6 @@ </div> - <script src="../lib/js/head.min.js"></script> <script src="../js/reveal.js"></script> <script src="qunit-2.5.0.js"></script> diff --git a/test/test.js b/test/test.js index f8515a0..2738403 100644 --- a/test/test.js +++ b/test/test.js @@ -262,6 +262,7 @@ Reveal.addEventListener( 'ready', function() { QUnit.test( 'Current fragment', function( assert ) { var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' ); + var lastFragmentIndex = [].slice.call( fragmentSlide.querySelectorAll( '.fragment' ) ).pop().getAttribute( 'data-fragment-index' ); Reveal.slide( 2, 0 ); assert.strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 0, 'no current fragment at index -1' ); @@ -274,6 +275,10 @@ Reveal.addEventListener( 'ready', function() { Reveal.slide( 3, 0, 0 ); assert.strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 0, 'no current fragment when navigating to next slide' ); + + Reveal.slide( 2, 1, -1 ); + Reveal.prev(); + assert.strictEqual( fragmentSlide.querySelector( '.fragment.current-fragment' ).getAttribute( 'data-fragment-index' ), lastFragmentIndex, 'last fragment is current fragment when returning from future slide' ); }); QUnit.test( 'Stepping through fragments', function( assert ) { |