Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 1 | <!doctype html> |
| 2 | <html lang="en"> |
| 3 | |
| 4 | <head> |
| 5 | <meta charset="utf-8"> |
| 6 | |
| 7 | <title>reveal.js - Test Iframes</title> |
| 8 | |
| 9 | <link rel="stylesheet" href="../dist/reveal.css"> |
| 10 | <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css"> |
| 11 | <script src="../node_modules/qunit/qunit/qunit.js"></script> |
| 12 | </head> |
| 13 | |
| 14 | <body style="overflow: auto;"> |
| 15 | |
| 16 | <div id="qunit"></div> |
| 17 | <div id="qunit-fixture"></div> |
| 18 | |
| 19 | <div class="deck1"> |
| 20 | <div class="reveal" style="display: none;"> |
| 21 | <div class="slides"> |
| 22 | <section>1.1</section> |
| 23 | <section data-state="deck1slide2">1.2</section> |
| 24 | <section>1.3</section> |
| 25 | </div> |
| 26 | </div> |
| 27 | </div> |
| 28 | |
| 29 | <div class="deck2"> |
| 30 | <div class="reveal" style="display: none;"> |
| 31 | <div class="slides"> |
| 32 | <section>2.1</section> |
| 33 | <section>2.2</section> |
| 34 | <section>2.3</section> |
| 35 | </div> |
| 36 | </div> |
| 37 | </div> |
| 38 | |
| 39 | <script type="module"> |
| 40 | |
| 41 | import Reveal from '../dist/reveal.esm.js'; |
| 42 | import Zoom from '../plugin/zoom/zoom.esm.js'; |
| 43 | |
Marc Kupietz | 09b7575 | 2023-10-07 09:32:19 +0200 | [diff] [blame] | 44 | QUnit.config.testTimeout = 30000; |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 45 | QUnit.module( 'Multiple reveal.js instances' ); |
| 46 | |
| 47 | let r1 = new Reveal( document.querySelector( '.deck1 .reveal' ), { |
| 48 | embedded: true, |
| 49 | keyboard: true, |
| 50 | plugins: [ Zoom ] |
| 51 | } ); |
| 52 | r1.initialize(); |
| 53 | |
| 54 | let r2 = new Reveal( document.querySelector( '.deck2 .reveal' ), { |
| 55 | embedded: true, |
| 56 | keyboard: false |
| 57 | } ); |
| 58 | r2.initialize(); |
| 59 | |
| 60 | QUnit.test( 'Can make independent changes', function( assert ) { |
| 61 | |
| 62 | r1.slide(1); |
| 63 | r2.slide(2); |
| 64 | assert.strictEqual( r1.getCurrentSlide().textContent, '1.2' ); |
| 65 | assert.strictEqual( r2.getCurrentSlide().textContent, '2.3' ); |
| 66 | |
| 67 | r2.toggleOverview( true ); |
| 68 | assert.strictEqual( r1.isOverview(), false ); |
| 69 | assert.strictEqual( r2.isOverview(), true ); |
| 70 | r2.toggleOverview( false ); |
| 71 | |
| 72 | assert.strictEqual( r1.getConfig().keyboard, true ); |
| 73 | assert.strictEqual( r2.getConfig().keyboard, false ); |
| 74 | |
| 75 | }); |
| 76 | |
| 77 | QUnit.test( 'Can register plugins independently', function( assert ) { |
| 78 | |
| 79 | assert.ok( r1.hasPlugin( 'zoom' ) ); |
| 80 | assert.notOk( r2.hasPlugin( 'zoom' ) ); |
| 81 | |
| 82 | }); |
| 83 | |
| 84 | QUnit.test( 'Slide state is set at the viewport level', function( assert ) { |
| 85 | |
| 86 | r1.slide(1); |
| 87 | |
| 88 | assert.ok( r1.getViewportElement().classList.contains( r1.getCurrentSlide().getAttribute( 'data-state' ) ) ); |
| 89 | |
| 90 | r1.slide(2); |
| 91 | |
| 92 | assert.ok( !r1.getViewportElement().classList.contains( r1.getCurrentSlide().getAttribute( 'data-state' ) ), 'unset' ); |
| 93 | |
| 94 | }); |
| 95 | |
| 96 | </script> |
| 97 | <script> |
| 98 | QUnit.test( 'Reveal does not leak to window', function( assert ) { |
| 99 | assert.strictEqual( window.Reveal, undefined ); |
| 100 | }); |
| 101 | </script> |
| 102 | |
| 103 | </body> |
| 104 | </html> |