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