1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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>
|