| 1 | <!doctype html> |
| 2 | <html lang="en"> |
| 3 | |
| 4 | <head> |
| 5 | <meta charset="utf-8"> |
| 6 | |
| 7 | <title>reveal.js - Test Dependencies</title> |
| 8 | </head> |
| 9 | |
| 10 | <body style="overflow: auto;"> |
| 11 | |
| 12 | <div id="qunit"></div> |
| 13 | <div id="qunit-fixture"></div> |
| 14 | |
| 15 | <div class="reveal deck1" style="display: none;"> |
| 16 | <div class="slides"> |
| 17 | <section>Slide content</section> |
| 18 | </div> |
| 19 | </div> |
| 20 | |
| 21 | <div class="reveal deck2" style="display: none;"> |
| 22 | <div class="slides"> |
| 23 | <section>Slide content</section> |
| 24 | </div> |
| 25 | </div> |
| 26 | |
| 27 | <script type="module"> |
| 28 | import 'reveal.css'; |
| 29 | import 'qunit/qunit/qunit.css'; |
| 30 | import QUnit from 'qunit'; |
| 31 | import Reveal from 'reveal.js'; |
| 32 | import Markdown from 'reveal.js/plugin/markdown'; |
| 33 | |
| 34 | QUnit.module( 'Destroy' ); |
| 35 | |
| 36 | QUnit.test( 'Destruction during initialization', function( assert ) { |
| 37 | |
| 38 | let deck = new Reveal( document.querySelector( '.deck1' ) ); |
| 39 | |
| 40 | deck.initialize({ plugins: [ Markdown ] }); |
| 41 | |
| 42 | let firstAttemptSuccess = false; |
| 43 | let repeatedAttemptSuccess = false; |
| 44 | |
| 45 | try { |
| 46 | deck.destroy(); |
| 47 | firstAttemptSuccess = true; |
| 48 | } |
| 49 | catch( error ) { |
| 50 | console.error( error ); |
| 51 | } |
| 52 | |
| 53 | assert.ok( firstAttemptSuccess, 'was successful' ); |
| 54 | |
| 55 | // should be able to destroy twice with no side effect |
| 56 | try { |
| 57 | deck.destroy(); |
| 58 | repeatedAttemptSuccess = true; |
| 59 | } |
| 60 | catch( error ) { |
| 61 | console.error( error ); |
| 62 | } |
| 63 | |
| 64 | assert.ok( repeatedAttemptSuccess, 'destroyed twice with no exceptions' ); |
| 65 | |
| 66 | } ); |
| 67 | |
| 68 | QUnit.test( 'Destruction after initialization', function( assert ) { |
| 69 | |
| 70 | assert.expect( 1 ); |
| 71 | let done = assert.async( 1 ); |
| 72 | let deck = new Reveal( document.querySelector( '.deck2' ) ); |
| 73 | |
| 74 | deck.initialize({ plugins: [ Markdown ] }).then(() => { |
| 75 | let wasSuccessful = false; |
| 76 | |
| 77 | try { |
| 78 | deck.destroy(); |
| 79 | wasSuccessful = true; |
| 80 | } |
| 81 | catch( error ) { |
| 82 | console.error( error ); |
| 83 | } |
| 84 | |
| 85 | if( wasSuccessful ) { |
| 86 | assert.ok( true, 'was successful' ); |
| 87 | } |
| 88 | |
| 89 | done(); |
| 90 | }); |
| 91 | |
| 92 | } ); |
| 93 | </script> |
| 94 | |
| 95 | </body> |
| 96 | </html> |
| 97 |