diff options
author | David Thompson <dthompson2@worcester.edu> | 2024-06-24 13:49:08 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2024-06-24 13:52:17 -0400 |
commit | d283f7e661e14d6ae1881fe803e5b4f1ed0689ff (patch) | |
tree | 84d3811c6dcb7d7f02aecadad7b2dfacce83bd4f /2024-06-18-guix-social/reveal.js/test | |
parent | 3d9dcd3099fb252fa35697148fbbd541eb9eecc9 (diff) |
Diffstat (limited to '2024-06-18-guix-social/reveal.js/test')
20 files changed, 2799 insertions, 0 deletions
diff --git a/2024-06-18-guix-social/reveal.js/test/assets/external-script-a.js b/2024-06-18-guix-social/reveal.js/test/assets/external-script-a.js new file mode 100644 index 0000000..cbc8da1 --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/assets/external-script-a.js @@ -0,0 +1 @@ +window.externalScriptSequence += 'A';
\ No newline at end of file diff --git a/2024-06-18-guix-social/reveal.js/test/assets/external-script-b.js b/2024-06-18-guix-social/reveal.js/test/assets/external-script-b.js new file mode 100644 index 0000000..e5bca5a --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/assets/external-script-b.js @@ -0,0 +1 @@ +window.externalScriptSequence += 'B';
\ No newline at end of file diff --git a/2024-06-18-guix-social/reveal.js/test/assets/external-script-c.js b/2024-06-18-guix-social/reveal.js/test/assets/external-script-c.js new file mode 100644 index 0000000..7d4ccf6 --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/assets/external-script-c.js @@ -0,0 +1 @@ +window.externalScriptSequence += 'C';
\ No newline at end of file diff --git a/2024-06-18-guix-social/reveal.js/test/assets/external-script-d.js b/2024-06-18-guix-social/reveal.js/test/assets/external-script-d.js new file mode 100644 index 0000000..1c5925b --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/assets/external-script-d.js @@ -0,0 +1 @@ +window.externalScriptSequence += 'D';
\ No newline at end of file diff --git a/2024-06-18-guix-social/reveal.js/test/simple.md b/2024-06-18-guix-social/reveal.js/test/simple.md new file mode 100644 index 0000000..97bae7e --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/simple.md @@ -0,0 +1,12 @@ +## Slide 1.1 + +```js +var a = 1; +``` + + +## Slide 1.2 + + + +## Slide 2
\ No newline at end of file diff --git a/2024-06-18-guix-social/reveal.js/test/test-auto-animate.html b/2024-06-18-guix-social/reveal.js/test/test-auto-animate.html new file mode 100644 index 0000000..a9c71f7 --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/test-auto-animate.html @@ -0,0 +1,167 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test Auto-Animate</title> + + <link rel="stylesheet" href="../dist/reveal.css"> + <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css"> + <script src="../node_modules/qunit/qunit/qunit.js"></script> + </head> + + <body style="overflow: auto;"> + + <div id="qunit"></div> + <div id="qunit-fixture"></div> + + <div class="reveal"> + + <div class="slides"> + + <section data-auto-animate> + <h1>h1</h1> + <h2>h2</h2> + <h3 style="position: absolute; left: 0;">h3</h3> + </section> + + <section data-auto-animate> + <h1 data-auto-animate-duration="0.1">h1</h1> + <h2 style="opacity: 0;">h2</h2> + <h3 style="position: absolute; left: 100px;">h3</h3> + </section> + + <section data-auto-animate data-auto-animate-duration="0.1"> + <h1>h1</h1> + <h2>h2</h2> + <h3>h3</h3> + </section> + + <section> + <h1>Non-auto-animate slide</h1> + </section> + + <section data-auto-animate> + <h1 class="fragment">h1</h1> + <h2 class="fragment">h2</h2> + <h3>h3</h3> + </section> + + <section data-auto-animate> + <h1 class="fragment">h1</h1> + <h2 class="fragment">h2</h2> + <h3 class="fragment">h3</h3> + </section> + + <section> + <h1>Non-auto-animate slide</h1> + </section> + + </div> + + </div> + + <script src="../dist/reveal.js"></script> + <script> + + QUnit.config.testTimeout = 30000; + QUnit.config.reorder = false; + + const slides = Array.prototype.map.call( document.querySelectorAll( '.slides section' ), slide => { + return { + slide: slide, + h1: slide.querySelector( 'h1' ), + h2: slide.querySelector( 'h2' ), + h3: slide.querySelector( 'h3' ) + }; + } ); + + Reveal.initialize().then( async () => { + + QUnit.module( 'Auto-Animate' ); + + QUnit.test( 'Adds data-auto-animate-target', assert => { + Reveal.slide(1); + assert.strictEqual( slides[0].h1.getAttribute( 'data-auto-animate-target' ), '', 'From elements have blank data-auto-animate-target' ); + assert.ok( slides[1].h1.getAttribute( 'data-auto-animate-target' ).length > 0, 'To elements have a data-auto-animate-target value' ); + }); + + QUnit.test( 'Ends on correct target styles', assert => { + Reveal.slide(1); + assert.strictEqual( slides[1].h2.style.opacity, "0" ); + assert.strictEqual( slides[1].h3.offsetLeft, 100 ); + }); + + QUnit.test( 'Does not add [data-auto-animate] on non auto-animated slides', assert => { + Reveal.slide(2); + Reveal.next(); + assert.ok( slides[3].slide.hasAttribute( 'data-auto-animate' ) === false ) + }); + + QUnit.test( 'autoAnimate config option', assert => { + Reveal.configure({ autoAnimate: false }); + + assert.ok( document.querySelectorAll( 'data-auto-animate-target' ).length === 0, 'Removes all [data-auto-animate-target]' ) + assert.ok( Array.prototype.every.call( document.querySelectorAll( 'section[data-auto-animate]' ), el => { + return el.dataset.autoAnimate === ''; + }, 'All data-auto-animate attributes are reset' ) ); + + Reveal.configure({ autoAnimate: true }); + }); + + QUnit.test( 'Carries forward matching fragment visibility', assert => { + Reveal.slide(4); + assert.ok( !slides[5].h1.classList.contains( 'visible' ) ) + Reveal.next(); + Reveal.next(); + Reveal.next(); + assert.ok( slides[5].h1.classList.contains( 'visible' ) ) + assert.ok( slides[5].h2.classList.contains( 'visible' ) ) + assert.ok( !slides[5].h3.classList.contains( 'visible' ) ) + Reveal.next(); + assert.ok( slides[5].h3.classList.contains( 'visible' ) ) + Reveal.next(); + assert.ok( slides[6].slide === Reveal.getCurrentSlide() ) + }); + + QUnit.test( 'Slide specific data-auto-animate-duration', assert => { + assert.timeout( 400 ); + assert.expect( 1 ); + + return new Promise( resolve => { + let callback = () => { + slides[2].h3.removeEventListener( 'transitionend', callback ); + assert.ok( true, 'Transition ended within time window' ); + resolve(); + } + + Reveal.slide(1); + Reveal.slide(2); + + slides[2].h3.addEventListener( 'transitionend', callback ); + } ); + }); + + // QUnit.test( 'Element specific data-auto-animate-duration', assert => { + // assert.timeout( 400 ); + // assert.expect( 1 ); + + // return new Promise( resolve => { + // let callback = () => { + // slides[1].h1.removeEventListener( 'transitionend', callback ); + // assert.ok( true, 'Transition ended within time window' ); + // resolve() + // } + + + // Reveal.slide(1); + // slides[1].h1.addEventListener( 'transitionend', callback ); + // } ); + // }); + + } ); + </script> + + </body> +</html> diff --git a/2024-06-18-guix-social/reveal.js/test/test-dependencies-async.html b/2024-06-18-guix-social/reveal.js/test/test-dependencies-async.html new file mode 100644 index 0000000..de14042 --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/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="../dist/reveal.css"> + <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css"> + <script src="../node_modules/qunit/qunit/qunit.js"></script> + </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="../dist/reveal.js"></script> + <script> + var externalScriptSequence = ''; + var scriptCount = 0; + + QUnit.config.testTimeout = 30000; + 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/2024-06-18-guix-social/reveal.js/test/test-dependencies.html b/2024-06-18-guix-social/reveal.js/test/test-dependencies.html new file mode 100644 index 0000000..cf3cf0e --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/test-dependencies.html @@ -0,0 +1,55 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test Dependencies</title> + + <link rel="stylesheet" href="../dist/reveal.css"> + <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css"> + <script src="../node_modules/qunit/qunit/qunit.js"></script> + </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="../dist/reveal.js"></script> + <script> + window.externalScriptSequence = ''; + + QUnit.config.testTimeout = 30000; + QUnit.config.autostart = false; + QUnit.module( 'Dependencies' ); + + Reveal.initialize({ + dependencies: [ + { src: 'assets/external-script-a.js' }, + { src: 'assets/external-script-b.js' }, + { src: 'assets/external-script-c.js' } + ] + }).then( () => { + + QUnit.start(); + + QUnit.test( 'Load synchronous scripts', function( assert ) { + assert.strictEqual( window.externalScriptSequence, 'ABC', 'Loaded and executed in order' ); + }); + + } ); + </script> + + </body> +</html> diff --git a/2024-06-18-guix-social/reveal.js/test/test-destroy.html b/2024-06-18-guix-social/reveal.js/test/test-destroy.html new file mode 100644 index 0000000..1fa9cd2 --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/test-destroy.html @@ -0,0 +1,97 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test Dependencies</title> + + <link rel="stylesheet" href="../dist/reveal.css"> + <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css"> + <script src="../node_modules/qunit/qunit/qunit.js"></script> + </head> + + <body style="overflow: auto;"> + + <div id="qunit"></div> + <div id="qunit-fixture"></div> + + <div class="reveal deck1" style="display: none;"> + <div class="slides"> + <section>Slide content</section> + </div> + </div> + + <div class="reveal deck2" style="display: none;"> + <div class="slides"> + <section>Slide content</section> + </div> + </div> + + <script type="module"> + import Reveal from '../dist/reveal.esm.js' + import Markdown from '../plugin/markdown/markdown.esm.js' + + QUnit.module( 'Destroy' ); + + QUnit.test( 'Destruction during initialization', function( assert ) { + + let deck = new Reveal( document.querySelector( '.deck1' ) ); + + deck.initialize({ plugins: [ Markdown ] }); + + let firstAttemptSuccess = false; + let repeatedAttemptSuccess = false; + + try { + deck.destroy(); + firstAttemptSuccess = true; + } + catch( error ) { + console.error( error ); + } + + assert.ok( firstAttemptSuccess, 'was successful' ); + + // should be able to destroy twice with no side effect + try { + deck.destroy(); + repeatedAttemptSuccess = true; + } + catch( error ) { + console.error( error ); + } + + assert.ok( repeatedAttemptSuccess, 'destroyed twice with no exceptions' ); + + } ); + + QUnit.test( 'Destruction after initialization', function( assert ) { + + assert.expect( 1 ); + let done = assert.async( 1 ); + let deck = new Reveal( document.querySelector( '.deck2' ) ); + + deck.initialize({ plugins: [ Markdown ] }).then(() => { + let wasSuccessful = false; + + try { + deck.destroy(); + wasSuccessful = true; + } + catch( error ) { + console.error( error ); + } + + if( wasSuccessful ) { + assert.ok( true, 'was successful' ); + } + + done(); + }); + + } ); + </script> + + </body> +</html> diff --git a/2024-06-18-guix-social/reveal.js/test/test-grid-navigation.html b/2024-06-18-guix-social/reveal.js/test/test-grid-navigation.html new file mode 100644 index 0000000..837764c --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/test-grid-navigation.html @@ -0,0 +1,75 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test Grid</title> + + <link rel="stylesheet" href="../dist/reveal.css"> + <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css"> + <script src="../node_modules/qunit/qunit/qunit.js"></script> + </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="../dist/reveal.js"></script> + <script> + QUnit.config.testTimeout = 30000; + QUnit.config.autostart = false; + QUnit.module( 'Grid Navigation' ); + + Reveal.initialize().then( () => { + + QUnit.start(); + + 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' ); + }); + + } ); + </script> + + </body> +</html> diff --git a/2024-06-18-guix-social/reveal.js/test/test-iframe-backgrounds.html b/2024-06-18-guix-social/reveal.js/test/test-iframe-backgrounds.html new file mode 100644 index 0000000..7df99a1 --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/test-iframe-backgrounds.html @@ -0,0 +1,100 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test Iframe Backgrounds</title> + + <link rel="stylesheet" href="../dist/reveal.css"> + <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css"> + <script src="../node_modules/qunit/qunit/qunit.js"></script> + </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-background-iframe="https://revealjs.com">1</section> + <section data-background-iframe="https://revealjs.com">2</section> + <section data-background-iframe="https://revealjs.com" data-preload>3</section> + <section data-background-iframe="https://revealjs.com">4</section> + <section data-background-iframe="https://revealjs.com">5</section> + <section data-background-iframe="https://revealjs.com">6</section> + + </div> + + </div> + + <script src="../dist/reveal.js"></script> + <script> + + QUnit.config.testTimeout = 30000; + + Reveal.initialize({ viewDistance: 3 }).then( () => { + + function getIframe( index ) { + return document.querySelectorAll( '.slide-background' )[index].querySelector( 'iframe' ); + } + + QUnit.module( 'Iframe' ); + + QUnit.test( 'Using default settings', function( assert ) { + + Reveal.slide(0); + assert.strictEqual( getIframe(1).hasAttribute( 'src' ), false, 'not preloaded when within viewDistance' ); + + Reveal.slide(1); + assert.strictEqual( getIframe(1).hasAttribute( 'src' ), true, 'loaded when slide becomes visible' ); + + Reveal.slide(0); + assert.strictEqual( getIframe(1).hasAttribute( 'src' ), false, 'unloaded when slide becomes invisible' ); + + }); + + QUnit.test( 'Using data-preload', function( assert ) { + + Reveal.slide(1); + assert.strictEqual( getIframe(2).hasAttribute( 'src' ), true, 'preloaded within viewDistance' ); + assert.strictEqual( getIframe(1).hasAttribute( 'src' ), true, 'loaded when slide becomes visible' ); + + Reveal.slide(0); + assert.strictEqual( getIframe(3).hasAttribute( 'src' ), false, 'unloads outside of viewDistance' ); + + }); + + QUnit.test( 'Using preloadIframes: true', function( assert ) { + + Reveal.configure({ preloadIframes: true }); + + Reveal.slide(1); + assert.strictEqual( getIframe(0).hasAttribute( 'src' ), true, 'preloaded within viewDistance' ); + assert.strictEqual( getIframe(1).hasAttribute( 'src' ), true, 'preloaded within viewDistance' ); + assert.strictEqual( getIframe(2).hasAttribute( 'src' ), true, 'preloaded within viewDistance' ); + + }); + + QUnit.test( 'Using preloadIframes: false', function( assert ) { + + Reveal.configure({ preloadIframes: false }); + + Reveal.slide(0); + assert.strictEqual( getIframe(1).hasAttribute( 'src' ), false, 'not preloaded within viewDistance' ); + assert.strictEqual( getIframe(2).hasAttribute( 'src' ), false, 'not preloaded within viewDistance' ); + + Reveal.slide(1); + assert.strictEqual( getIframe(1).hasAttribute( 'src' ), true, 'loaded when slide becomes visible' ); + + + }); + + } ); + </script> + + </body> +</html> diff --git a/2024-06-18-guix-social/reveal.js/test/test-iframes.html b/2024-06-18-guix-social/reveal.js/test/test-iframes.html new file mode 100644 index 0000000..fa4b434 --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/test-iframes.html @@ -0,0 +1,104 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test Iframes</title> + + <link rel="stylesheet" href="../dist/reveal.css"> + <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css"> + <script src="../node_modules/qunit/qunit/qunit.js"></script> + </head> + + <body style="overflow: auto;"> + + <div id="qunit"></div> + <div id="qunit-fixture"></div> + + <div class="reveal" style="display: none;"> + + <div class="slides"> + + <section>1</section> + <section>2</section> + <section> + <iframe class="default-iframe" data-src="#"></iframe> + <iframe class="preload-iframe" data-src="#" data-preload></iframe> + </section> + + </div> + + </div> + + <script src="../dist/reveal.js"></script> + <script> + + QUnit.config.testTimeout = 30000; + + Reveal.initialize({ viewDistance: 2 }).then( () => { + + var defaultIframe = document.querySelector( '.default-iframe' ), + preloadIframe = document.querySelector( '.preload-iframe' ); + + QUnit.module( 'Iframe' ); + + QUnit.test( 'Using default settings', function( assert ) { + + Reveal.slide(1); + assert.strictEqual( defaultIframe.hasAttribute( 'src' ), false, 'not preloaded when within viewDistance' ); + + Reveal.slide(2); + assert.strictEqual( defaultIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' ); + + Reveal.slide(1); + assert.strictEqual( defaultIframe.hasAttribute( 'src' ), false, 'unloaded when slide becomes invisible' ); + + }); + + QUnit.test( 'Using data-preload', function( assert ) { + + Reveal.slide(1); + assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'preloaded within viewDistance' ); + + Reveal.slide(2); + assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'loaded when slide becoems visible' ); + + Reveal.slide(0); + assert.strictEqual( preloadIframe.hasAttribute( 'src' ), false, 'unloads outside of viewDistance' ); + + }); + + QUnit.test( 'Using preloadIframes: true', function( assert ) { + + Reveal.configure({ preloadIframes: true }); + + Reveal.slide(1); + assert.strictEqual( defaultIframe.hasAttribute( 'src' ), true, 'preloaded within viewDistance' ); + assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'preloaded within viewDistance' ); + + Reveal.slide(2); + assert.strictEqual( defaultIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' ); + assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' ); + + }); + + QUnit.test( 'Using preloadIframes: false', function( assert ) { + + Reveal.configure({ preloadIframes: false }); + + Reveal.slide(0); + assert.strictEqual( defaultIframe.hasAttribute( 'src' ), false, 'not preloaded within viewDistance' ); + assert.strictEqual( preloadIframe.hasAttribute( 'src' ), false, 'not preloaded within viewDistance' ); + + Reveal.slide(2); + assert.strictEqual( defaultIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' ); + assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' ); + + }); + + } ); + </script> + + </body> +</html> diff --git a/2024-06-18-guix-social/reveal.js/test/test-markdown.html b/2024-06-18-guix-social/reveal.js/test/test-markdown.html new file mode 100644 index 0000000..e877284 --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/test-markdown.html @@ -0,0 +1,516 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test Markdown</title> + + <link rel="stylesheet" href="../dist/reveal.css"> + <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css"> + <script src="../node_modules/qunit/qunit/qunit.js"></script> + </head> + + <body style="overflow: auto;"> + + <div id="qunit"></div> + <div id="qunit-fixture"></div> + + <div class="reveal deck1" style="display: none;"> + <div class="slides"> + <section data-markdown data-separator="^\n---\n$" data-separator-vertical="^\n--\n$"> + <script type="text/template"> + ## Slide 1.1 + + -- + + ## Slide 1.2 + + --- + + ## Slide 2 + </script> + </section> + </div> + </div> + + <div class="reveal deck2" 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> + </div> + </div> + + <div class="reveal deck3" style="display: none;"> + <div class="slides"> + <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> + + <div class="reveal deck4" style="display: none;"> + <div class="slides"> + <section data-markdown> + <script type="text/template"> + ## Testing Markdown Options + + This "slide" should contain 'smart' quotes. + </script> + </section> + </div> + </div> + + <div class="reveal deck5" style="display: none;"> + <div class="slides"> + <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 grow"} --> + - list item 2 <!-- {_class="fragment grow"} --> + - list item 3 <!-- {_class="fragment grow"} --> + + + --- + + ## 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> + + <div class="reveal deck6" style="display: block;"> + <div class="slides"> + <section data-markdown class="defaults"> + <script type="text/template"> + ``` + code + ``` + </script> + </section> + <section data-markdown class="with-language"> + <script type="text/template"> + ```javascript + code + ``` + </script> + </section> + <section data-markdown class="with-line-numbers"> + <script type="text/template"> + ```[] + code + ``` + </script> + </section> + <section data-markdown class="with-line-highlights"> + <script type="text/template"> + ```[1,2,3] + code + ``` + </script> + </section> + <section data-markdown class="with-offset"> + <script type="text/template"> + ```[123:] + code + ``` + </script> + </section> + <section data-markdown class="with-line-highlights-and-lanugage"> + <script type="text/template"> + ```javascript [1,2,3] + code + ``` + </script> + </section> + <section data-markdown class="with-line-highlights-offset-and-lanugage"> + <script type="text/template"> + ```javascript [456: 3,4,5] + code + ``` + </script> + </section> + <section data-markdown class="with-line-offset-and-lanugage"> + <script type="text/template"> + ```javascript [756:] + code + ``` + </script> + </section> + <section data-markdown class="with-code-in-fragment"> + <script type="text/template"> + ```js + foo.bar(); + ``` + + <!-- .element: class="fragment" --> + </script> + </section> + </div> + </div> + + <script type="module"> + import Reveal from '../dist/reveal.esm.js' + import Markdown from '../plugin/markdown/markdown.esm.js' + import Highlight from '../plugin/highlight/highlight.esm.js' + + QUnit.config.testTimeout = 30000; + + let deck1 = new Reveal( document.querySelector( '.deck1' ), { plugins: [ Markdown ] }) + deck1.addEventListener( 'ready', function() { + + QUnit.module( 'Inline' ); + + QUnit.test( 'Vertical separator', function( assert ) { + assert.strictEqual( deck1.getRevealElement().querySelectorAll( '.reveal .slides>section>section' ).length, 2, 'found two slides' ); + }); + + QUnit.test( 'Horizontal separator', function( assert ) { + assert.strictEqual( deck1.getRevealElement().querySelectorAll( '.reveal .slides>section' ).length, 2, 'found two slides' ); + }); + + } ); + + let deck2 = new Reveal( document.querySelector( '.deck2' ), { plugins: [ Markdown ] }) + deck2.addEventListener( 'ready', function() { + + QUnit.module( 'External' ); + + QUnit.test( 'Vertical separator', function( assert ) { + assert.strictEqual( deck2.getRevealElement().querySelectorAll( '.reveal .slides>section>section' ).length, 2, 'found two slides' ); + }); + + QUnit.test( 'Horizontal separator', function( assert ) { + assert.strictEqual( deck2.getRevealElement().querySelectorAll( '.reveal .slides>section' ).length, 2, 'found two slides' ); + }); + + } ); + + let deck3 = new Reveal( document.querySelector( '.deck3' ), { plugins: [ Markdown ] }) + deck3.addEventListener( 'ready', function() { + + QUnit.module( 'Slide Attributes' ); + + QUnit.test( 'Id on slide', function( assert ) { + assert.strictEqual( deck3.getRevealElement().querySelectorAll( '.reveal .slides>section>section#slide2' ).length, 1, 'found one slide with id slide2' ); + assert.strictEqual( deck3.getRevealElement().querySelectorAll( '.reveal .slides>section>section a[href="#/slide2"]' ).length, 1, 'found one slide with a link to slide2' ); + }); + + QUnit.test( 'data-background attributes', function( assert ) { + assert.strictEqual( deck3.getRevealElement().querySelectorAll( '.reveal .slides>section>section[data-background="#A0C66B"]' ).length, 1, 'found one vertical slide with data-background="#A0C66B"' ); + assert.strictEqual( deck3.getRevealElement().querySelectorAll( '.reveal .slides>section>section[data-background="#ff0000"]' ).length, 1, 'found one vertical slide with data-background="#ff0000"' ); + assert.strictEqual( deck3.getRevealElement().querySelectorAll( '.reveal .slides>section[data-background="#C6916B"]' ).length, 1, 'found one slide with data-background="#C6916B"' ); + }); + + QUnit.test( 'data-transition attributes', function( assert ) { + assert.strictEqual( deck3.getRevealElement().querySelectorAll( '.reveal .slides>section>section[data-transition="zoom"]' ).length, 1, 'found one vertical slide with data-transition="zoom"' ); + assert.strictEqual( deck3.getRevealElement().querySelectorAll( '.reveal .slides>section>section[data-transition="fade"]' ).length, 1, 'found one vertical slide with data-transition="fade"' ); + assert.strictEqual( deck3.getRevealElement().querySelectorAll( '.reveal .slides section [data-transition="zoom"]' ).length, 1, 'found one slide with data-transition="zoom"' ); + }); + + QUnit.test( 'data-background attributes with default separator', function( assert ) { + assert.strictEqual( deck3.getRevealElement().querySelectorAll( '.reveal .slides>section>section[data-background="#A7C66B"]' ).length, 1, 'found one vertical slide with data-background="#A0C66B"' ); + assert.strictEqual( deck3.getRevealElement().querySelectorAll( '.reveal .slides>section>section[data-background="#f70000"]' ).length, 1, 'found one vertical slide with data-background="#ff0000"' ); + assert.strictEqual( deck3.getRevealElement().querySelectorAll( '.reveal .slides>section[data-background="#C7916B"]' ).length, 1, 'found one slide with data-background="#C6916B"' ); + }); + + QUnit.test( 'data-transition attributes with default separator', function( assert ) { + assert.strictEqual( deck3.getRevealElement().querySelectorAll( '.reveal .slides>section>section[data-transition="concave"]' ).length, 1, 'found one vertical slide with data-transition="zoom"' ); + assert.strictEqual( deck3.getRevealElement().querySelectorAll( '.reveal .slides>section>section[data-transition="page"]' ).length, 1, 'found one vertical slide with data-transition="fade"' ); + assert.strictEqual( deck3.getRevealElement().querySelectorAll( '.reveal .slides section [data-transition="concave"]' ).length, 1, 'found one slide with data-transition="zoom"' ); + }); + + QUnit.test( 'data-transition attributes with inline content', function( assert ) { + assert.strictEqual( deck3.getRevealElement().querySelectorAll( '.reveal .slides>section[data-background="#ff0000"]' ).length, 3, 'found three horizontal slides with data-background="#ff0000"' ); + }); + + } ); + + let deck4 = new Reveal( document.querySelector( '.deck4' ), { + markdown: { + smartypants: true + }, + plugins: [ Markdown ] + }) + deck4.addEventListener( 'ready', function() { + + QUnit.module( 'Options' ); + + QUnit.test( 'Options are set', function( assert ) { + assert.strictEqual( deck4.getPlugin( 'markdown' ).marked.defaults.smartypants, true ); + }); + + QUnit.test( 'Smart quotes are activated', function( assert ) { + var text = deck4.getRevealElement().querySelector( '.reveal .slides>section>p' ).textContent; + + assert.strictEqual( /['"]/.test( text ), false ); + assert.strictEqual( /[“”‘’]/.test( text ), true ); + }); + + } ); + + let deck5 = new Reveal( document.querySelector( '.deck5' ), { plugins: [ Markdown ] }) + deck5.addEventListener( 'ready', function() { + + QUnit.module( 'Element Attributes' ); + + QUnit.test( 'Vertical separator', function( assert ) { + assert.strictEqual( deck5.getRevealElement().querySelectorAll( '.reveal .slides>section>section' ).length, 4, 'found four slides' ); + }); + + QUnit.test( 'Attributes on element header in vertical slides', function( assert ) { + assert.strictEqual( deck5.getRevealElement().querySelectorAll( '.reveal .slides section>section h2.fragment.fade-out' ).length, 1, 'found one vertical slide with class fragment.fade-out on header' ); + assert.strictEqual( deck5.getRevealElement().querySelectorAll( '.reveal .slides section>section h2.fragment.shrink' ).length, 1, 'found one vertical slide with class fragment.shrink on header' ); + }); + + QUnit.test( 'Attributes on element paragraphs in vertical slides', function( assert ) { + assert.strictEqual( deck5.getRevealElement().querySelectorAll( '.reveal .slides section>section p.fragment.grow' ).length, 2, 'found a vertical slide with two paragraphs with class fragment.grow' ); + }); + + QUnit.test( 'Attributes on element list items in vertical slides', function( assert ) { + assert.strictEqual( deck5.getRevealElement().querySelectorAll( '.reveal .slides section>section li.fragment.grow' ).length, 3, 'found a vertical slide with three list items with class fragment.grow' ); + }); + + QUnit.test( 'Attributes on element paragraphs in horizontal slides', function( assert ) { + assert.strictEqual( deck5.getRevealElement().querySelectorAll( '.reveal .slides section p.fragment.highlight-red' ).length, 4, 'found a horizontal slide with four paragraphs with class fragment.grow' ); + }); + + QUnit.test( 'Attributes on element list items in horizontal slides', function( assert ) { + assert.strictEqual( deck5.getRevealElement().querySelectorAll( '.reveal .slides section li.fragment.highlight-green' ).length, 5, 'found a horizontal slide with five list items with class fragment.roll-in' ); + }); + + QUnit.test( 'Attributes on element image in horizontal slides', function( assert ) { + assert.strictEqual( deck5.getRevealElement().querySelectorAll( '.reveal .slides section img.reveal.stretch' ).length, 1, 'found a horizontal slide with stretched image, class img.reveal.stretch' ); + }); + + QUnit.test( 'Attributes on elements in vertical slides with default element attribute separator', function( assert ) { + assert.strictEqual( deck5.getRevealElement().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' ); + }); + + QUnit.test( 'Attributes on elements in single slides with default element attribute separator', function( assert ) { + assert.strictEqual( deck5.getRevealElement().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' ); + }); + + } ); + + let deck6 = new Reveal( document.querySelector( '.deck6' ), { + plugins: [ Markdown, Highlight ] + }) + deck6.addEventListener( 'ready', function() { + + QUnit.module( 'Code Blocks' ); + + QUnit.test( 'Defaults to no line numbers', function( assert ) { + assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.defaults .hljs:not([data-line-numbers])' ).length, 1 ); + }); + + QUnit.test( 'Can set language', function( assert ) { + assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-language .hljs.javascript:not([data-line-numbers])' ).length, 1 ); + }); + + QUnit.test( '```[] enables line numbers', function( assert ) { + assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-line-numbers .hljs[data-line-numbers=""]' ).length, 1 ); + }); + + QUnit.test( '```[1,2,3] enables line highlights', function( assert ) { + assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-line-highlights .hljs[data-line-numbers="1,2,3"]' ).length, 1 ); + }); + + QUnit.test( '```[234: ] line offset only', function( assert ) { + assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-offset .hljs[data-ln-start-from="123"]' ).length, 1 ); + }); + + QUnit.test( '```javascript [1,2,3] enables line highlights and sets language', function( assert ) { + assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-line-highlights-and-lanugage .hljs.javascript[data-line-numbers="1,2,3"]' ).length, 1 ); + }); + + QUnit.test( '```javascript [123: 3,4,5] add line offset and enables line highlights and sets language', function( assert ) { + assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-line-highlights-offset-and-lanugage .hljs.javascript[data-line-numbers="3,4,5"]' ).length, 1 ); + assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-line-highlights-offset-and-lanugage .hljs.javascript[data-ln-start-from="456"]' ).length, 1 ); + }); + + QUnit.test( '```javascript [756:] add line offset and sets no line highlights and sets language', function( assert ) { + assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-line-offset-and-lanugage .hljs.javascript[data-ln-start-from="756"]' ).length, 1 ); + }); + + QUnit.test( '```block should allow custom fragment', function( assert ) { + assert.strictEqual( deck6.getRevealElement().querySelectorAll( '.with-code-in-fragment pre.fragment' ).length, 1 ); + }); + + } ); + + deck1.initialize(); + deck2.initialize(); + deck3.initialize(); + deck4.initialize(); + deck5.initialize(); + deck6.initialize(); + </script> + + </body> +</html> diff --git a/2024-06-18-guix-social/reveal.js/test/test-multiple-instances-es5.html b/2024-06-18-guix-social/reveal.js/test/test-multiple-instances-es5.html new file mode 100644 index 0000000..c8bb189 --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/test-multiple-instances-es5.html @@ -0,0 +1,86 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test Iframes</title> + + <link rel="stylesheet" href="../dist/reveal.css"> + <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css"> + <script src="../node_modules/qunit/qunit/qunit.js"></script> + </head> + + <body style="overflow: auto;"> + + <div id="qunit"></div> + <div id="qunit-fixture"></div> + + <div class="deck1"> + <div class="reveal" style="display: none;"> + <div class="slides"> + <section>1.1</section> + <section>1.2</section> + <section>1.3</section> + </div> + </div> + </div> + + <div class="deck2"> + <div class="reveal" style="display: none;"> + <div class="slides"> + <section>2.1</section> + <section>2.2</section> + <section>2.3</section> + </div> + </div> + </div> + + <script src="../dist/reveal.js"></script> + <script src="../plugin/zoom/zoom.js"></script> + <script> + + QUnit.config.testTimeout = 30000; + QUnit.module( 'Multiple reveal.js instances' ); + + let r1 = new Reveal( document.querySelector( '.deck1 .reveal' ), { + embedded: true, + keyboard: true, + plugins: [RevealZoom()] + } ); + r1.initialize(); + + let r2 = new Reveal( document.querySelector( '.deck2 .reveal' ), { + embedded: true, + keyboard: false + } ); + r2.initialize(); + + QUnit.test( 'Can make independent changes', function( assert ) { + + r1.slide(1); + r2.slide(2); + assert.strictEqual( r1.getCurrentSlide().textContent, '1.2' ); + assert.strictEqual( r2.getCurrentSlide().textContent, '2.3' ); + + r2.toggleOverview( true ); + assert.strictEqual( r1.isOverview(), false ); + assert.strictEqual( r2.isOverview(), true ); + r2.toggleOverview( false ); + + assert.strictEqual( r1.getConfig().keyboard, true ); + assert.strictEqual( r2.getConfig().keyboard, false ); + + }); + + QUnit.test( 'Can register plugins independently', function( assert ) { + + assert.ok( r1.hasPlugin( 'zoom' ) ); + assert.notOk( r2.hasPlugin( 'zoom' ) ); + + }); + + </script> + + </body> +</html> diff --git a/2024-06-18-guix-social/reveal.js/test/test-multiple-instances.html b/2024-06-18-guix-social/reveal.js/test/test-multiple-instances.html new file mode 100644 index 0000000..4f16d7e --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/test-multiple-instances.html @@ -0,0 +1,104 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test Iframes</title> + + <link rel="stylesheet" href="../dist/reveal.css"> + <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css"> + <script src="../node_modules/qunit/qunit/qunit.js"></script> + </head> + + <body style="overflow: auto;"> + + <div id="qunit"></div> + <div id="qunit-fixture"></div> + + <div class="deck1"> + <div class="reveal" style="display: none;"> + <div class="slides"> + <section>1.1</section> + <section data-state="deck1slide2">1.2</section> + <section>1.3</section> + </div> + </div> + </div> + + <div class="deck2"> + <div class="reveal" style="display: none;"> + <div class="slides"> + <section>2.1</section> + <section>2.2</section> + <section>2.3</section> + </div> + </div> + </div> + + <script type="module"> + + import Reveal from '../dist/reveal.esm.js'; + import Zoom from '../plugin/zoom/zoom.esm.js'; + + QUnit.config.testTimeout = 30000; + QUnit.module( 'Multiple reveal.js instances' ); + + let r1 = new Reveal( document.querySelector( '.deck1 .reveal' ), { + embedded: true, + keyboard: true, + plugins: [ Zoom ] + } ); + r1.initialize(); + + let r2 = new Reveal( document.querySelector( '.deck2 .reveal' ), { + embedded: true, + keyboard: false + } ); + r2.initialize(); + + QUnit.test( 'Can make independent changes', function( assert ) { + + r1.slide(1); + r2.slide(2); + assert.strictEqual( r1.getCurrentSlide().textContent, '1.2' ); + assert.strictEqual( r2.getCurrentSlide().textContent, '2.3' ); + + r2.toggleOverview( true ); + assert.strictEqual( r1.isOverview(), false ); + assert.strictEqual( r2.isOverview(), true ); + r2.toggleOverview( false ); + + assert.strictEqual( r1.getConfig().keyboard, true ); + assert.strictEqual( r2.getConfig().keyboard, false ); + + }); + + QUnit.test( 'Can register plugins independently', function( assert ) { + + assert.ok( r1.hasPlugin( 'zoom' ) ); + assert.notOk( r2.hasPlugin( 'zoom' ) ); + + }); + + QUnit.test( 'Slide state is set at the viewport level', function( assert ) { + + r1.slide(1); + + assert.ok( r1.getViewportElement().classList.contains( r1.getCurrentSlide().getAttribute( 'data-state' ) ) ); + + r1.slide(2); + + assert.ok( !r1.getViewportElement().classList.contains( r1.getCurrentSlide().getAttribute( 'data-state' ) ), 'unset' ); + + }); + + </script> + <script> + QUnit.test( 'Reveal does not leak to window', function( assert ) { + assert.strictEqual( window.Reveal, undefined ); + }); + </script> + + </body> +</html> diff --git a/2024-06-18-guix-social/reveal.js/test/test-pdf.html b/2024-06-18-guix-social/reveal.js/test/test-pdf.html new file mode 100644 index 0000000..8fa102a --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/test-pdf.html @@ -0,0 +1,97 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test PDF exports</title> + + <link rel="stylesheet" href="../dist/reveal.css"> + <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css"> + <script src="../node_modules/qunit/qunit/qunit.js"></script> + </head> + + <body style="overflow: auto;"> + + <div id="qunit"></div> + <div id="qunit-fixture"></div> + + <div class="reveal" style="display: none;"> + + <div class="slides"> + + <section> + <h1>1</h1> + <img data-src=""> + </section> + + <section> + <section> + <h1>2.1</h1> + </section> + <section> + <h1>2.2</h1> + </section> + <section> + <h1>2.3</h1> + </section> + </section> + + <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> + <h1>4</h1> + </section> + + </div> + + </div> + + <script src="../dist/reveal.js"></script> + <script> + QUnit.config.testTimeout = 30000; + QUnit.config.autostart = false; + + Reveal.initialize({ pdf: true }).then( function() { + + QUnit.start(); + + // Only one test for now, we're mainly ensuring that there + // are no execution errors when running PDF mode + + QUnit.test( 'Reveal.isReady', function( assert ) { + assert.strictEqual( Reveal.isReady(), true, 'returns true' ); + }); + + } ); + + </script> + + </body> +</html> diff --git a/2024-06-18-guix-social/reveal.js/test/test-plugins.html b/2024-06-18-guix-social/reveal.js/test/test-plugins.html new file mode 100644 index 0000000..f9cd5b1 --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/test-plugins.html @@ -0,0 +1,108 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test Plugins</title> + + <link rel="stylesheet" href="../dist/reveal.css"> + <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css"> + <script src="../node_modules/qunit/qunit/qunit.js"></script> + </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="../dist/reveal.js"></script> + <script> + + QUnit.config.testTimeout = 30000; + QUnit.module( 'Plugins' ); + + var initCounter = { PluginB: 0, PluginC: 0, PluginD: 0 }; + + // Plugin with no init method + var PluginA = { id: 'PluginA' }; + + // Plugin with init method + var PluginB = { id: 'PluginB', init: function() { + initCounter['PluginB'] += 1; + } }; + + // Async plugin with init method + var PluginC = { id: 'PluginC', init: function() { + return new Promise(function( resolve ) { + setTimeout( () => { + initCounter['PluginC'] += 1; + resolve(); + }, 1000 ); + }); + } }; + + // Plugin initialized after reveal.js is ready + var PluginD = { id: 'PluginD', init: function() { + initCounter['PluginD'] += 1; + } }; + + var PluginE = { id: 'PluginE' }; + + var reveal = new Reveal( document.querySelector( '.reveal' ), { + plugins: [ PluginA ] + } ); + + reveal.registerPlugin( PluginB ); + reveal.registerPlugin( PluginC ); + + reveal.initialize(); + + QUnit.test( 'Can initialize synchronously', function( assert ) { + assert.strictEqual( initCounter['PluginB'], 1 ); + + reveal.registerPlugin( PluginB ); + + assert.strictEqual( initCounter['PluginB'], 1, 'prevents duplicate registration' ); + }); + + QUnit.test( 'Can initialize asynchronously', function( assert ) { + assert.expect( 3 ); + var done = assert.async( 2 ); + + assert.strictEqual( initCounter['PluginC'], 0, 'async plugin not immediately initialized' ); + + reveal.on( 'ready', function() { + assert.strictEqual( initCounter['PluginC'], 1, 'finsihed initializing when reveal.js dispatches "ready"' ); + done(); + + reveal.registerPlugin( PluginD ); + assert.strictEqual( initCounter['PluginD'], 1, 'plugin registered after reveal.js is ready still initiailizes' ); + done(); + }); + } ); + + QUnit.test( 'Can check if plugin is registered', function( assert ) { + assert.strictEqual( reveal.hasPlugin( 'PluginA' ), true ); + assert.strictEqual( reveal.hasPlugin( 'PluginE' ), false ); + reveal.registerPlugin( PluginE ); + assert.strictEqual( reveal.hasPlugin( 'PluginE' ), true ); + } ); + + QUnit.test( 'Can retrieve plugin instance', function( assert ) { + assert.strictEqual( reveal.getPlugin( 'PluginB' ), PluginB ); + } ); + </script> + + </body> +</html> diff --git a/2024-06-18-guix-social/reveal.js/test/test-scroll.html b/2024-06-18-guix-social/reveal.js/test/test-scroll.html new file mode 100644 index 0000000..74a16e3 --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/test-scroll.html @@ -0,0 +1,162 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test Scroll View</title> + + <link rel="stylesheet" href="../dist/reveal.css"> + <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css"> + <script src="../node_modules/qunit/qunit/qunit.js"></script> + </head> + + <body style="overflow: auto;"> + + <div id="qunit"></div> + <div id="qunit-fixture"></div> + + <div class="reveal" style="opacity: 0; pointer-events: none;"> + + <div class="slides"> + + <section> + <h1>slide 1</h1> + </section> + + <section> + <h1>slide 2</h1> + </section> + + <section> + <h1>slide 3</h1> + <p class="fragment">fragment 1</p> + <p class="fragment">fragment 2</p> + <p class="fragment">fragment 3</p> + </section> + + <section> + <h1>slide 4</h1> + </section> + + </div> + + </div> + + <script src="../dist/reveal.js"></script> + <script> + + QUnit.config.testTimeout = 30000; + QUnit.config.reorder = false; + + function getScrollHeight() { + return Reveal.getViewportElement().scrollHeight; + } + + function getViewportHeight() { + return Reveal.getViewportElement().offsetHeight; + } + + Reveal.initialize({ view: 'scroll' }).then( async () => { + + QUnit.module( 'Scroll View' ); + + QUnit.test( 'Activates', assert => { + assert.ok( getScrollHeight() > getViewportHeight(), 'Is overflowing' ); + }); + + QUnit.test( 'Can be toggled via API', assert => { + Reveal.toggleScrollView( false ); + assert.ok( getScrollHeight() <= getViewportHeight(), 'Is not overflowing' ); + Reveal.toggleScrollView( true ); + assert.ok( getScrollHeight() > getViewportHeight(), 'Is overflowing' ); + }); + + QUnit.test( 'Changes present slide when scrolling', assert => { + assert.timeout( 200 ); + assert.expect( 2 ); + + const slides = document.querySelectorAll( '.reveal .slides section' ); + + assert.ok( slides[0].classList.contains( 'present' ), 'First slide is present' ); + Reveal.getViewportElement().scrollTop = getViewportHeight() * 1; + + return new Promise( resolve => { + setTimeout(() => { + assert.ok( slides[1].classList.contains( 'present' ), 'Second slide is present' ); + resolve(); + }, 100); + } ); + }); + + QUnit.test( 'Fires slideschanged event when scrolling', assert => { + assert.timeout( 200 ); + assert.expect( 2 ); + + const slides = document.querySelectorAll( '.reveal .slides section' ); + + return new Promise( resolve => { + let callback = ( event ) => { + Reveal.off( 'slidechanged', callback ); + assert.ok( true, 'slidechanged event fired' ); + assert.ok( event.currentSlide.classList.contains( 'present' ), 'slidechanged provides reference to currentSlide' ); + resolve(); + } + + Reveal.on( 'slidechanged', callback ); + Reveal.getViewportElement().scrollTop = getViewportHeight() * 2; + }); + }); + + QUnit.test( 'Fires fragmentshown event when scrolling', assert => { + assert.timeout( 200 ); + assert.expect( 2 ); + + const slides = document.querySelectorAll( '.reveal .slides section' ); + + return new Promise( resolve => { + let callback = ( event ) => { + Reveal.off( 'fragmentshown', callback ); + assert.ok( true, 'fragmentshown event fired' ); + assert.ok( event.fragments.length > 0, 'fragmentshown provides reference to fragment nodes' ); + resolve(); + } + + Reveal.on( 'fragmentshown', callback ); + + Reveal.getViewportElement().scrollTop = 0; + Reveal.next(); + Reveal.next(); + Reveal.getViewportElement().scrollTop += getViewportHeight(); + }); + }); + + QUnit.test( 'Fires fragmenthidden event when scrolling', assert => { + assert.timeout( 200 ); + assert.expect( 2 ); + + const slides = document.querySelectorAll( '.reveal .slides section' ); + + return new Promise( resolve => { + let callback = ( event ) => { + Reveal.off( 'fragmenthidden', callback ); + assert.ok( true, 'fragmenthidden event fired' ); + assert.ok( event.fragments.length > 0, 'fragmenthidden provides reference to fragment nodes' ); + resolve(); + } + + Reveal.on( 'fragmenthidden', callback ); + + Reveal.getViewportElement().scrollTop = 0; + Reveal.next(); + Reveal.next(); + Reveal.next(); + Reveal.getViewportElement().scrollTop -= getViewportHeight(); + }); + }); + + } ); + </script> + + </body> +</html> diff --git a/2024-06-18-guix-social/reveal.js/test/test-state.html b/2024-06-18-guix-social/reveal.js/test/test-state.html new file mode 100644 index 0000000..c2d5055 --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/test-state.html @@ -0,0 +1,134 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Test State</title> + + <link rel="stylesheet" href="../dist/reveal.css"> + <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css"> + <script src="../node_modules/qunit/qunit/qunit.js"></script> + </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="../dist/reveal.js"></script> + <script> + + Reveal.initialize(); + + 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.on( 'state1', _onState1 ); + Reveal.on( 'state2', _onState2 ); + + Reveal.slide( 1 ); + Reveal.slide( 3 ); + + Reveal.off( 'state1', _onState1 ); + Reveal.off( '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.on( 'state1', _onState1 ); + Reveal.on( 'state3', _onState3 ); + + Reveal.slide( 0 ); + Reveal.slide( 4, 1 ); + Reveal.slide( 4, 2 ); + + Reveal.off( 'state1', _onState1 ); + Reveal.off( 'state3', _onState3 ); + }); + + QUnit.test( 'No events if state remains unchanged', function( assert ) { + var stateChanges = 0; + + var _onEvent = function( event ) { + stateChanges += 1; + } + + Reveal.on( '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.off( '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.on( 'state1', _onEvent ); + + Reveal.slide( 0 ); + Reveal.slide( 1 ); + + Reveal.off( 'state1', _onEvent ); + }); + + </script> + + </body> +</html> diff --git a/2024-06-18-guix-social/reveal.js/test/test.html b/2024-06-18-guix-social/reveal.js/test/test.html new file mode 100644 index 0000000..ab44922 --- /dev/null +++ b/2024-06-18-guix-social/reveal.js/test/test.html @@ -0,0 +1,900 @@ +<!doctype html> +<html lang="en"> + + <head> + <meta charset="utf-8"> + + <title>reveal.js - Tests</title> + + <link rel="stylesheet" href="../dist/reveal.css"> + <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css"> + <script src="../node_modules/qunit/qunit/qunit.js"></script> + </head> + + <body style="overflow: auto;"> + + <div id="qunit"></div> + <div id="qunit-fixture"></div> + + <div class="reveal" style="visibility: hidden;"> + + <div class="slides"> + + <section data-visibility="hidden"> + This should be remove by reveal.js before our tests run. + </section> + + <section data-background-image="examples/assets/image1.png"> + <h1>1</h1> + <img data-src=""> + <video data-src=""></video> + <audio data-src=""></audio> + <aside class="notes">speaker notes 1</aside> + </section> + + <section> + <section data-background="examples/assets/image2.png" data-notes="speaker notes 2"> + <h1>2.1</h1> + </section> + <section data-background-image="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4gIcSUNDX1BST0ZJTEUAAQEAAAIMbGNtcwIQAABtbnRyUkdCIFhZWiAH3AABABkAAwApADlhY3NwQVBQTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLWxjbXMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAApkZXNjAAAA/"> + <h1>2.2</h1> + </section> + <section> + <h1>2.3</h1> + </section> + </section> + + <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> + <iframe data-src="http://example.com"></iframe> + </section> + + <section id="fragments3"> + <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> + <h1>4</h1> + </section> + + </div> + + </div> + + <script src="../dist/reveal.js"></script> + <script> + QUnit.config.testTimeout = 30000; + + window.location.hash = ''; + + Reveal.configure({maxScale: 1.11}); + + // These tests expect the DOM to contain a presentation + // with the following slide structure: + // + // 1 + // 2 - Three sub-slides + // 3 - Three fragment elements + // 3 - Two fragments with same data-fragment-index + // 4 + Reveal.initialize().then( function() { + + // Helper methods + function triggerKeyboardEvent(config) { + document.dispatchEvent( new KeyboardEvent( 'keydown', config ) ); + } + + // --------------------------------------------------------------- + // DOM TESTS + + QUnit.module( 'DOM' ); + + QUnit.test( 'Initial slides classes', function( assert ) { + var horizontalSlides = document.querySelectorAll( '.reveal .slides>section' ) + + assert.strictEqual( document.querySelectorAll( '.reveal .slides section[data-visibility="hidden"]' ).length, 0, 'no data-visibility="hidden" slides' ); + assert.strictEqual( document.querySelectorAll( '.reveal .slides section.past' ).length, 0, 'no .past slides' ); + assert.strictEqual( document.querySelectorAll( '.reveal .slides section.present' ).length, 1, 'one .present slide' ); + assert.strictEqual( document.querySelectorAll( '.reveal .slides>section.future' ).length, horizontalSlides.length - 1, 'remaining horizontal slides are .future' ); + + assert.strictEqual( document.querySelectorAll( '.reveal .slides section.stack' ).length, 2, 'two .stacks' ); + + assert.ok( document.querySelectorAll( '.reveal .slides section.stack' )[0].querySelectorAll( '.future' ).length > 0, 'vertical slides are given .future' ); + }); + + // --------------------------------------------------------------- + // API TESTS + + QUnit.module( 'API' ); + + QUnit.test( 'Reveal.configure before initialization', function( assert ) { + assert.strictEqual( Reveal.getConfig().maxScale, 1.11 ); + }); + + QUnit.test( 'Reveal.isReady', function( assert ) { + assert.strictEqual( Reveal.isReady(), true, 'returns true' ); + }); + + QUnit.test( 'Reveal.isOverview', function( assert ) { + assert.strictEqual( Reveal.isOverview(), false, 'false by default' ); + + Reveal.toggleOverview(); + assert.strictEqual( Reveal.isOverview(), true, 'true after toggling on' ); + + Reveal.toggleOverview(); + assert.strictEqual( Reveal.isOverview(), false, 'false after toggling off' ); + }); + + QUnit.test( 'Reveal.isPaused', function( assert ) { + assert.strictEqual( Reveal.isPaused(), false, 'false by default' ); + + Reveal.togglePause(); + assert.strictEqual( Reveal.isPaused(), true, 'true after pausing' ); + + Reveal.togglePause(); + assert.strictEqual( Reveal.isPaused(), false, 'false after resuming' ); + }); + + QUnit.test( 'Reveal.isFirstSlide', function( assert ) { + Reveal.slide( 0, 0 ); + assert.strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 0, 0 )' ); + + Reveal.slide( 1, 0 ); + assert.strictEqual( Reveal.isFirstSlide(), false, 'false after Reveal.slide( 1, 0 )' ); + + Reveal.slide( 0, 0 ); + assert.strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 0, 0 )' ); + }); + + QUnit.test( 'Reveal.isFirstSlide after vertical slide', function( assert ) { + Reveal.slide( 1, 1 ); + Reveal.slide( 0, 0 ); + assert.strictEqual( Reveal.isFirstSlide(), true, 'true after Reveal.slide( 1, 1 ) and then Reveal.slide( 0, 0 )' ); + }); + + QUnit.test( 'Reveal.isLastSlide', function( assert ) { + Reveal.slide( 0, 0 ); + assert.strictEqual( Reveal.isLastSlide(), false, 'false after Reveal.slide( 0, 0 )' ); + + var lastSlideIndex = document.querySelectorAll( '.reveal .slides>section' ).length - 1; + + Reveal.slide( lastSlideIndex, 0 ); + assert.strictEqual( Reveal.isLastSlide(), true, 'true after Reveal.slide( '+ lastSlideIndex +', 0 )' ); + + Reveal.slide( 0, 0 ); + assert.strictEqual( Reveal.isLastSlide(), false, 'false after Reveal.slide( 0, 0 )' ); + }); + + QUnit.test( 'Reveal.isLastSlide after vertical slide', function( assert ) { + var lastSlideIndex = document.querySelectorAll( '.reveal .slides>section' ).length - 1; + + Reveal.slide( 1, 1 ); + Reveal.slide( lastSlideIndex ); + assert.strictEqual( Reveal.isLastSlide(), true, 'true after Reveal.slide( 1, 1 ) and then Reveal.slide( '+ lastSlideIndex +', 0 )' ); + }); + + QUnit.test( 'Reveal.getTotalSlides', function( assert ) { + assert.strictEqual( Reveal.getTotalSlides(), 8, 'eight slides in total' ); + }); + + QUnit.test( 'Reveal.getIndices', function( assert ) { + var indices = Reveal.getIndices(); + + assert.ok( indices.hasOwnProperty( 'h' ), 'h exists' ); + assert.ok( indices.hasOwnProperty( 'v' ), 'v exists' ); + assert.ok( indices.hasOwnProperty( 'f' ), 'f exists' ); + + Reveal.slide( 1, 0 ); + assert.strictEqual( Reveal.getIndices().h, 1, 'h 1' ); + assert.strictEqual( Reveal.getIndices().v, 0, 'v 0' ); + + Reveal.slide( 1, 2 ); + assert.strictEqual( Reveal.getIndices().h, 1, 'h 1' ); + assert.strictEqual( Reveal.getIndices().v, 2, 'v 2' ); + + Reveal.slide( 0, 0 ); + assert.strictEqual( Reveal.getIndices().h, 0, 'h 0' ); + assert.strictEqual( Reveal.getIndices().v, 0, 'v 0' ); + }); + + QUnit.test( 'Reveal.getSlide', function( assert ) { + assert.equal( Reveal.getSlide( 0 ), document.querySelector( '.reveal .slides>section:first-child' ), 'gets correct first slide' ); + assert.equal( Reveal.getSlide( 1 ), document.querySelector( '.reveal .slides>section:nth-child(2)' ), 'no v index returns stack' ); + assert.equal( Reveal.getSlide( 1, 0 ), document.querySelector( '.reveal .slides>section:nth-child(2)>section:nth-child(1)' ), 'v index 0 returns first vertical child' ); + assert.equal( Reveal.getSlide( 1, 1 ), document.querySelector( '.reveal .slides>section:nth-child(2)>section:nth-child(2)' ), 'v index 1 returns second vertical child' ); + + assert.strictEqual( Reveal.getSlide( 100 ), undefined, 'undefined when out of horizontal bounds' ); + assert.strictEqual( Reveal.getSlide( 1, 100 ), undefined, 'undefined when out of vertical bounds' ); + }); + + QUnit.test( 'Reveal.getSlideBackground', function( assert ) { + assert.equal( Reveal.getSlideBackground( 0 ), document.querySelector( '.reveal .backgrounds>.slide-background:first-child' ), 'gets correct first background' ); + assert.equal( Reveal.getSlideBackground( 1 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2)' ), 'no v index returns stack' ); + assert.equal( Reveal.getSlideBackground( 1, 0 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2) .slide-background:nth-child(2)' ), 'v index 0 returns first vertical child' ); + assert.equal( Reveal.getSlideBackground( 1, 1 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2) .slide-background:nth-child(3)' ), 'v index 1 returns second vertical child' ); + + assert.strictEqual( Reveal.getSlideBackground( 100 ), undefined, 'undefined when out of horizontal bounds' ); + assert.strictEqual( Reveal.getSlideBackground( 1, 100 ), undefined, 'undefined when out of vertical bounds' ); + }); + + QUnit.test( 'Reveal.getSlideNotes', function( assert ) { + Reveal.slide( 0, 0 ); + assert.ok( Reveal.getSlideNotes() === 'speaker notes 1', 'works with <aside class="notes">' ); + + Reveal.slide( 1, 0 ); + assert.ok( Reveal.getSlideNotes() === 'speaker notes 2', 'works with <section data-notes="">' ); + }); + + QUnit.test( 'Reveal.getPreviousSlide/getCurrentSlide', function( assert ) { + Reveal.slide( 0, 0 ); + Reveal.slide( 1, 0 ); + + var firstSlide = document.querySelector( '.reveal .slides>section:first-child' ); + var secondSlide = document.querySelector( '.reveal .slides>section:nth-child(2)>section' ); + + assert.equal( Reveal.getPreviousSlide(), firstSlide, 'previous is slide #0' ); + assert.equal( Reveal.getCurrentSlide(), secondSlide, 'current is slide #1' ); + }); + + QUnit.test( 'Reveal.getProgress', function( assert ) { + Reveal.slide( 0, 0 ); + assert.strictEqual( Reveal.getProgress(), 0, 'progress is 0 on first slide' ); + + var lastSlideIndex = document.querySelectorAll( '.reveal .slides>section' ).length - 1; + + Reveal.slide( lastSlideIndex, 0 ); + assert.strictEqual( Reveal.getProgress(), 1, 'progress is 1 on last slide' ); + }); + + QUnit.test( 'Reveal.getScale', function( assert ) { + assert.ok( typeof Reveal.getScale() === 'number', 'has scale' ); + }); + + QUnit.test( 'Reveal.getConfig', function( assert ) { + assert.ok( typeof Reveal.getConfig() === 'object', 'has config' ); + }); + + QUnit.test( 'Reveal.configure', function( assert ) { + assert.strictEqual( Reveal.getConfig().loop, false, '"loop" is false to start with' ); + + Reveal.configure({ loop: true }); + assert.strictEqual( Reveal.getConfig().loop, true, '"loop" has changed to true' ); + + Reveal.configure({ loop: false, customTestValue: 1 }); + assert.strictEqual( Reveal.getConfig().customTestValue, 1, 'supports custom values' ); + }); + + QUnit.test( 'Reveal.availableRoutes', function( assert ) { + Reveal.slide( 0, 0 ); + assert.deepEqual( Reveal.availableRoutes(), { left: false, up: false, down: false, right: true }, 'correct for first slide' ); + + Reveal.slide( 1, 0 ); + assert.deepEqual( Reveal.availableRoutes(), { left: true, up: false, down: true, right: true }, 'correct for vertical slide' ); + + Reveal.slide( 0, 0 ); + assert.deepEqual( Reveal.availableRoutes({ includeFragments: true }), { left: false, up: false, down: false, right: true }, 'correct with fragments included' ); + }); + + QUnit.test( 'Reveal.next', function( assert ) { + Reveal.slide( 0, 0 ); + + // Step through vertical child slides + Reveal.next(); + assert.deepEqual( Reveal.getIndices(), { h: 1, v: 0, f: undefined } ); + + Reveal.next(); + assert.deepEqual( Reveal.getIndices(), { h: 1, v: 1, f: undefined } ); + + Reveal.next(); + assert.deepEqual( Reveal.getIndices(), { h: 1, v: 2, f: undefined } ); + + // Step through fragments + Reveal.next(); + assert.deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: -1 } ); + + Reveal.next(); + assert.deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 } ); + + Reveal.next(); + assert.deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 } ); + + Reveal.next(); + assert.deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 } ); + }); + + QUnit.test( 'Reveal.next at end', function( assert ) { + Reveal.slide( 3 ); + + // We're at the end, this should have no effect + Reveal.next(); + assert.deepEqual( Reveal.getIndices(), { h: 3, v: 0, f: undefined } ); + + Reveal.next(); + assert.deepEqual( Reveal.getIndices(), { h: 3, v: 0, f: undefined } ); + }); + + + // --------------------------------------------------------------- + // URL TESTS + + QUnit.module( 'URL' ); + + QUnit.test( 'Write (fragmentInURL: false)', function( assert ) { + Reveal.configure({ hash: true, fragmentInURL: false }); + + Reveal.slide( 2, 0 ); + assert.strictEqual( Reveal.getSlidePath(), '/2' ); + + Reveal.slide( 2, 1 ); + assert.strictEqual( Reveal.getSlidePath(), '/2/1' ); + + Reveal.slide( 2, 0, 1 ); + assert.strictEqual( Reveal.getSlidePath(), '/2' ); + + Reveal.slide( 2, 2, 0 ); + assert.strictEqual( Reveal.getSlidePath(), '/fragments3' ); + + Reveal.slide( 2, 2, 1 ); + assert.strictEqual( Reveal.getSlidePath(), '/fragments3' ); + }); + + QUnit.test( 'Write (fragmentInURL: true)', function( assert ) { + Reveal.configure({ hash: true, fragmentInURL: true }); + + Reveal.slide( 2, 0, -1 ); + assert.strictEqual( Reveal.getSlidePath(), '/2' ); + + Reveal.slide( 2, 1, -1 ); + assert.strictEqual( Reveal.getSlidePath(), '/2/1' ); + + Reveal.slide( 2, 0, 1 ); + assert.strictEqual( Reveal.getSlidePath(), '/2/0/1' ); + + Reveal.slide( 2, 2, -1 ); + assert.strictEqual( Reveal.getSlidePath(), '/fragments3' ); + + Reveal.slide( 2, 2, 1 ); + assert.strictEqual( Reveal.getSlidePath(), '/fragments3/1' ); + }); + + QUnit.test( 'Read', async function( assert ) { + Reveal.configure({ hash: true, fragmentInURL: true }); + + let test = function( hash, indices ) { + return new Promise( resolve => { + window.onhashchange = () => { + assert.deepEqual( Reveal.getIndices(), indices ); + resolve(); + }; + window.location.hash = hash; + } ); + } + + await test( '#/0', { h: 0, v: 0, f: undefined } ); // horizontal + await test( '#/1/1', { h: 1, v: 1, f: undefined } ); // vertical + await test( '#/0/', { h: 0, v: 0, f: undefined } ); // trailing / + await test( '#/1/1/', { h: 1, v: 1, f: undefined } ); // trailing / + await test( '#/2/0/1', { h: 2, v: 0, f: 1 } ); // fragment + }); + + // --------------------------------------------------------------- + // KEYBOARD TESTS + + QUnit.module( 'Keyboard' ); + + QUnit.test( 'Add key bindings', function( assert ) { + var done = assert.async( 1 ); + + Reveal.addKeyBinding({keyCode: 88, key: 'X', description: 'X-SHORTCUT-X'}, function() { + assert.ok( true, 'callback triggered' ); + done(); + } ); + + Reveal.toggleHelp( true ); + assert.ok( /X\-SHORTCUT\-X/.test( document.body.innerHTML ), 'binding is added to help overlay' ); + Reveal.toggleHelp( false ); + + triggerKeyboardEvent({ keyCode: 88 }); + + Reveal.removeKeyBinding( 88 ); + + // should do nothing + triggerKeyboardEvent({ keyCode: 88 }); + }); + + QUnit.test( 'Navigation bindings', function( assert ) { + Reveal.slide( 0 ); + + // right arrow + triggerKeyboardEvent({ keyCode: 39 }); + assert.strictEqual( Reveal.getIndices().h, 1 ); + + // down arrow + shift + triggerKeyboardEvent({ keyCode: 40, shiftKey: true }); + assert.strictEqual( Reveal.getIndices().v, 2, 'shift + down arrow goes to last vertical slide' ); + + // up arrow + triggerKeyboardEvent({ keyCode: 38 }); + assert.strictEqual( Reveal.getIndices().v, 1 ); + + // right arrow + shift + triggerKeyboardEvent({ keyCode: 39, shiftKey: true }); + assert.ok( Reveal.isLastSlide(), 'shift + right arrow goes to last horizontal slide' ); + + + // right arrow on slide with fragments + Reveal.slide( 2, 0, -1 ); + triggerKeyboardEvent({ keyCode: 39 }); + assert.deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'right arrow shows fragment' ); + + triggerKeyboardEvent({ keyCode: 39, altKey: true }); + assert.strictEqual( Reveal.getIndices().h, 3, 'right arrow skips fragments when alt key is pressed' ); + }); + + // --------------------------------------------------------------- + // FRAGMENT TESTS + + QUnit.module( 'Fragments' ); + + QUnit.test( 'Sliding to fragments', function( assert ) { + Reveal.slide( 2, 0, -1 ); + assert.deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: -1 }, 'Reveal.slide( 2, 0, -1 )' ); + + Reveal.slide( 2, 0, 0 ); + assert.deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'Reveal.slide( 2, 0, 0 )' ); + + Reveal.slide( 2, 0, 2 ); + assert.deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 }, 'Reveal.slide( 2, 0, 2 )' ); + + Reveal.slide( 2, 0, 1 ); + assert.deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'Reveal.slide( 2, 0, 1 )' ); + }); + + QUnit.test( 'data-fragment is set on slide <section>', function( assert ) { + Reveal.slide( 2, 0, -1 ); + assert.deepEqual( Reveal.getCurrentSlide().getAttribute( 'data-fragment' ), '-1' ); + + Reveal.slide( 2, 0, 2 ); + assert.deepEqual( Reveal.getCurrentSlide().getAttribute( 'data-fragment' ), '2' ); + + Reveal.slide( 2, 0, 0 ); + assert.deepEqual( Reveal.getCurrentSlide().getAttribute( 'data-fragment' ), '0' ); + + var fragmentSlide = Reveal.getCurrentSlide(); + + Reveal.slide( 3, 0 ); + assert.deepEqual( fragmentSlide.getAttribute( 'data-fragment' ), '0', 'data-fragment persists when jumping to another slide' ); + }); + + QUnit.test( 'Hiding all fragments', function( assert ) { + var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' ); + + Reveal.slide( 2, 0, 0 ); + assert.strictEqual( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 1, 'one fragment visible when index is 0' ); + + Reveal.slide( 2, 0, -1 ); + assert.strictEqual( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 0, 'no fragments visible when index is -1' ); + }); + + 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' ); + + Reveal.slide( 2, 0, 0 ); + assert.strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 1, 'one current fragment at index 0' ); + + Reveal.slide( 1, 0, 0 ); + assert.strictEqual( fragmentSlide.querySelectorAll( '.fragment.current-fragment' ).length, 0, 'no current fragment when navigating to previous slide' ); + + 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 ) { + Reveal.slide( 2, 0, -1 ); + + // forwards: + + Reveal.next(); + assert.deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'next() goes to next fragment' ); + + Reveal.right(); + assert.deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'right() goes to next fragment' ); + + Reveal.down(); + assert.deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 }, 'down() goes to next fragment' ); + + Reveal.down(); // moves to f #3 + + // backwards: + + Reveal.prev(); + assert.deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 2 }, 'prev() goes to prev fragment' ); + + Reveal.left(); + assert.deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 1 }, 'left() goes to prev fragment' ); + + Reveal.up(); + assert.deepEqual( Reveal.getIndices(), { h: 2, v: 0, f: 0 }, 'up() goes to prev fragment' ); + }); + + QUnit.test( 'Stepping past fragments', function( assert ) { + var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' ); + + Reveal.slide( 0, 0, 0 ); + assert.equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 0, 'no fragments visible when on previous slide' ); + + Reveal.slide( 3, 0, 0 ); + assert.equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 3, 'all fragments visible when on future slide' ); + }); + + QUnit.test( 'Fragment indices', function( assert ) { + var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(2)' ); + + Reveal.slide( 3, 0, 0 ); + assert.equal( fragmentSlide.querySelectorAll( '.fragment.visible' ).length, 2, 'both fragments of same index are shown' ); + + // This slide has three fragments, first one is index 0, second and third have index 1 + Reveal.slide( 2, 2, 0 ); + assert.equal( Reveal.getIndices().f, 0, 'returns correct index for first fragment' ); + + Reveal.slide( 2, 2, 1 ); + assert.equal( Reveal.getIndices().f, 1, 'returns correct index for two fragments with same index' ); + }); + + QUnit.test( 'Index generation', function( assert ) { + var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(1)' ); + + // These have no indices defined to start with + assert.equal( fragmentSlide.querySelectorAll( '.fragment' )[0].getAttribute( 'data-fragment-index' ), '0' ); + assert.equal( fragmentSlide.querySelectorAll( '.fragment' )[1].getAttribute( 'data-fragment-index' ), '1' ); + assert.equal( fragmentSlide.querySelectorAll( '.fragment' )[2].getAttribute( 'data-fragment-index' ), '2' ); + }); + + QUnit.test( 'Index normalization', function( assert ) { + var fragmentSlide = document.querySelector( '#fragment-slides>section:nth-child(3)' ); + + // These start out as 1-4-4 and should normalize to 0-1-1 + assert.equal( fragmentSlide.querySelectorAll( '.fragment' )[0].getAttribute( 'data-fragment-index' ), '0' ); + assert.equal( fragmentSlide.querySelectorAll( '.fragment' )[1].getAttribute( 'data-fragment-index' ), '1' ); + assert.equal( fragmentSlide.querySelectorAll( '.fragment' )[2].getAttribute( 'data-fragment-index' ), '1' ); + }); + + QUnit.test( 'fragmentshown event', function( assert ) { + assert.expect( 2 ); + var done = assert.async( 2 ); + + var _onEvent = function( event ) { + assert.ok( true, 'event fired' ); + done(); + } + + Reveal.on( 'fragmentshown', _onEvent ); + + Reveal.slide( 2, 0 ); + Reveal.slide( 2, 0 ); // should do nothing + Reveal.slide( 2, 0, 0 ); // should do nothing + Reveal.next(); + Reveal.next(); + Reveal.prev(); // shouldn't fire fragmentshown + + Reveal.off( 'fragmentshown', _onEvent ); + }); + + QUnit.test( 'fragmenthidden event', function( assert ) { + assert.expect( 2 ); + var done = assert.async( 2 ); + + var _onEvent = function( event ) { + assert.ok( true, 'event fired' ); + done(); + } + + Reveal.on( 'fragmenthidden', _onEvent ); + + Reveal.slide( 2, 0, 2 ); + Reveal.slide( 2, 0, 2 ); // should do nothing + Reveal.prev(); + Reveal.prev(); + Reveal.next(); // shouldn't fire fragmenthidden + + Reveal.off( 'fragmenthidden', _onEvent ); + }); + + + // --------------------------------------------------------------- + // AUTO-SLIDE TESTS + + QUnit.module( 'Auto Sliding' ); + + QUnit.test( 'Reveal.isAutoSliding', function( assert ) { + assert.strictEqual( Reveal.isAutoSliding(), false, 'false by default' ); + + Reveal.configure({ autoSlide: 10000 }); + assert.strictEqual( Reveal.isAutoSliding(), true, 'true after starting' ); + + Reveal.configure({ autoSlide: 0 }); + assert.strictEqual( Reveal.isAutoSliding(), false, 'false after setting to 0' ); + }); + + QUnit.test( 'Reveal.toggleAutoSlide', function( assert ) { + Reveal.configure({ autoSlide: 10000 }); + + Reveal.toggleAutoSlide(); + assert.strictEqual( Reveal.isAutoSliding(), false, 'false after first toggle' ); + Reveal.toggleAutoSlide(); + assert.strictEqual( Reveal.isAutoSliding(), true, 'true after second toggle' ); + + Reveal.configure({ autoSlide: 0 }); + }); + + QUnit.test( 'autoslidepaused', function( assert ) { + assert.expect( 1 ); + var done = assert.async(); + + var _onEvent = function( event ) { + assert.ok( true, 'event fired' ); + done(); + } + + Reveal.on( 'autoslidepaused', _onEvent ); + Reveal.configure({ autoSlide: 10000 }); + Reveal.toggleAutoSlide(); + + // cleanup + Reveal.configure({ autoSlide: 0 }); + Reveal.off( 'autoslidepaused', _onEvent ); + }); + + QUnit.test( 'autoslideresumed', function( assert ) { + assert.expect( 1 ); + var done = assert.async(); + + var _onEvent = function( event ) { + assert.ok( true, 'event fired' ); + done(); + } + + Reveal.on( 'autoslideresumed', _onEvent ); + Reveal.configure({ autoSlide: 10000 }); + Reveal.toggleAutoSlide(); + Reveal.toggleAutoSlide(); + + // cleanup + Reveal.configure({ autoSlide: 0 }); + Reveal.off( 'autoslideresumed', _onEvent ); + }); + + + // --------------------------------------------------------------- + // CONFIGURATION VALUES + + QUnit.module( 'Configuration' ); + + QUnit.test( 'Controls', function( assert ) { + var controlsElement = document.querySelector( '.reveal>.controls' ); + + Reveal.configure({ controls: false }); + assert.equal( controlsElement.style.display, 'none', 'controls are hidden' ); + + Reveal.configure({ controls: true }); + assert.equal( controlsElement.style.display, 'block', 'controls are visible' ); + }); + + QUnit.test( 'Progress', function( assert ) { + var progressElement = document.querySelector( '.reveal>.progress' ); + + Reveal.configure({ progress: false }); + assert.equal( progressElement.style.display, 'none', 'progress are hidden' ); + + Reveal.configure({ progress: true }); + assert.equal( progressElement.style.display, 'block', 'progress are visible' ); + }); + + QUnit.test( 'Loop', function( assert ) { + Reveal.configure({ loop: true }); + + Reveal.slide( 0, 0 ); + + Reveal.left(); + assert.notEqual( Reveal.getIndices().h, 0, 'looped from start to end' ); + + Reveal.right(); + assert.equal( Reveal.getIndices().h, 0, 'looped from end to start' ); + + Reveal.configure({ navigationMode: 'linear' }); + Reveal.slide( 0, 0 ); + + Reveal.prev(); + assert.notEqual( Reveal.getIndices().h, 0, 'looped from start to end in linear mode' ); + + Reveal.next(); + assert.equal( Reveal.getIndices().h, 0, 'looped from end to start in linear mode' ); + + Reveal.configure({ loop: false, navigationMode: 'default' }); + }); + + + // --------------------------------------------------------------- + // LAZY-LOADING TESTS + + QUnit.module( 'Lazy-Loading' ); + + QUnit.test( 'img with data-src', function( assert ) { + assert.strictEqual( document.querySelectorAll( '.reveal section img[src]' ).length, 1, 'Image source has been set' ); + }); + + QUnit.test( 'video with data-src', function( assert ) { + assert.strictEqual( document.querySelectorAll( '.reveal section video[src]' ).length, 1, 'Video source has been set' ); + }); + + QUnit.test( 'audio with data-src', function( assert ) { + assert.strictEqual( document.querySelectorAll( '.reveal section audio[src]' ).length, 1, 'Audio source has been set' ); + }); + + QUnit.test( 'iframe with data-src', function( assert ) { + Reveal.slide( 0, 0 ); + assert.strictEqual( document.querySelectorAll( '.reveal section iframe[src]' ).length, 0, 'Iframe source is not set' ); + Reveal.slide( 2, 1 ); + assert.strictEqual( document.querySelectorAll( '.reveal section iframe[src]' ).length, 1, 'Iframe source is set' ); + Reveal.slide( 2, 2 ); + assert.strictEqual( document.querySelectorAll( '.reveal section iframe[src]' ).length, 0, 'Iframe source is not set' ); + }); + + QUnit.test( 'background images', function( assert ) { + var imageSource1 = Reveal.getSlide( 0 ).getAttribute( 'data-background-image' ); + var imageSource2 = Reveal.getSlide( 1, 0 ).getAttribute( 'data-background' ); + var imageSource3 = Reveal.getSlide( 1, 1 ).getAttribute( 'data-background-image' ); + + // check that the images are applied to the background elements + assert.ok( Reveal.getSlideBackground( 0 ).querySelector( '.slide-background-content' ).style.backgroundImage.indexOf( imageSource1 ) !== -1, 'data-background-image worked' ); + assert.ok( Reveal.getSlideBackground( 1, 0 ).querySelector( '.slide-background-content' ).style.backgroundImage.indexOf( imageSource2 ) !== -1, 'data-background worked' ); + assert.ok( Reveal.getSlideBackground( 1, 1 ).querySelector( '.slide-background-content' ).style.backgroundImage.indexOf( imageSource3 ) !== -1, 'data-background worked' ); + }); + + + // --------------------------------------------------------------- + // EVENT TESTS + + QUnit.module( 'Events' ); + + QUnit.test( 'beforeslidechange', function( assert ) { + var done = assert.async( 2 ); + + var normalEvent = function( event ) { + assert.ok( true, 'event fired' ); + done(); + } + var blockingEvent = function( event ) { + event.preventDefault(); + assert.ok( true, 'event fired' ); + done(); + } + + Reveal.on( 'beforeslidechange', normalEvent ); + Reveal.slide( 2, 0 ); + Reveal.off( 'beforeslidechange', normalEvent ); + + Reveal.on( 'beforeslidechange', blockingEvent ); + Reveal.slide( 3, 0 ); + Reveal.off( 'beforeslidechange', blockingEvent ); + + assert.strictEqual( Reveal.getIndices().h, 2, 'preventing "beforeslidechange" blocks navigation ' ); + + }); + + QUnit.test( 'slidechanged', function( assert ) { + assert.expect( 3 ); + var done = assert.async( 3 ); + + var _onEvent = function( event ) { + assert.ok( true, 'event fired' ); + done(); + } + + Reveal.on( 'slidechanged', _onEvent ); + + Reveal.slide( 1, 0 ); // should trigger + Reveal.slide( 1, 0 ); // should do nothing + Reveal.next(); // should trigger + Reveal.slide( 3, 0 ); // should trigger + Reveal.next(); // should do nothing + + Reveal.off( 'slidechanged', _onEvent ); + + }); + + /* Fails intermittently... + QUnit.test( 'slidetransitionend', function( assert ) { + assert.expect( 2 ); + let done = assert.async( 2 ); + let time = Date.now(); + + let horizontalCallback = event => { + assert.ok( Date.now() - time > 200, 'horizontal event fired' ); + done(); + + let verticalCallback = event => { + assert.ok( true, 'vertical event fired' ); + done(); + Reveal.off( 'slidetransitionend', verticalCallback ); + } + + Reveal.off( 'slidetransitionend', horizontalCallback ); + Reveal.on( 'slidetransitionend', verticalCallback ); + Reveal.slide( 1, 1 ); + } + + Reveal.slide( 0, 0 ); + Reveal.on( 'slidetransitionend', horizontalCallback ); + Reveal.slide( 1, 0 ); + + }); + */ + + QUnit.test( 'paused', function( assert ) { + assert.expect( 1 ); + var done = assert.async(); + + var _onEvent = function( event ) { + assert.ok( true, 'event fired' ); + done(); + } + + Reveal.on( 'paused', _onEvent ); + + Reveal.togglePause(); + Reveal.togglePause(); + + Reveal.off( 'paused', _onEvent ); + }); + + QUnit.test( 'resumed', function( assert ) { + assert.expect( 1 ); + var done = assert.async(); + + var _onEvent = function( event ) { + assert.ok( true, 'event fired' ); + done(); + } + + Reveal.on( 'resumed', _onEvent ); + + Reveal.togglePause(); + Reveal.togglePause(); + + Reveal.off( 'resumed', _onEvent ); + }); + + } ); + </script> + + </body> +</html> |