refactor unit tests, now consistently initializing reveal.js in the same way

This commit is contained in:
Hakim El Hattab 2020-03-07 18:19:08 +01:00
parent 20b8def298
commit 0814176f3c
22 changed files with 214 additions and 244 deletions

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="../dist/reveal.css"> <link rel="stylesheet" href="../dist/reveal.css">
<link rel="stylesheet" href="qunit-2.5.0.css"> <link rel="stylesheet" href="qunit-2.5.0.css">
<script src="qunit-2.5.0.js"></script>
</head> </head>
<body style="overflow: auto;"> <body style="overflow: auto;">
@ -46,8 +47,6 @@
</div> </div>
<script src="../dist/reveal.min.js"></script> <script src="../dist/reveal.min.js"></script>
<script src="qunit-2.5.0.js"></script>
<script> <script>
const slides = Array.prototype.map.call( document.querySelectorAll( '.slides section' ), slide => { const slides = Array.prototype.map.call( document.querySelectorAll( '.slides section' ), slide => {
@ -59,7 +58,7 @@
}; };
} ); } );
Reveal.addEventListener( 'ready', () => { Reveal.initialize().then( () => {
QUnit.module( 'Auto-Animate' ); QUnit.module( 'Auto-Animate' );
@ -121,8 +120,6 @@
}); });
} ); } );
Reveal.initialize();
</script> </script>
</body> </body>

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="../dist/reveal.css"> <link rel="stylesheet" href="../dist/reveal.css">
<link rel="stylesheet" href="qunit-2.5.0.css"> <link rel="stylesheet" href="qunit-2.5.0.css">
<script src="qunit-2.5.0.js"></script>
</head> </head>
<body style="overflow: auto;"> <body style="overflow: auto;">
@ -26,8 +27,6 @@
</div> </div>
<script src="../dist/reveal.min.js"></script> <script src="../dist/reveal.min.js"></script>
<script src="qunit-2.5.0.js"></script>
<script> <script>
var externalScriptSequence = ''; var externalScriptSequence = '';
var scriptCount = 0; var scriptCount = 0;

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="../dist/reveal.css"> <link rel="stylesheet" href="../dist/reveal.css">
<link rel="stylesheet" href="qunit-2.5.0.css"> <link rel="stylesheet" href="qunit-2.5.0.css">
<script src="qunit-2.5.0.js"></script>
</head> </head>
<body style="overflow: auto;"> <body style="overflow: auto;">
@ -26,12 +27,16 @@
</div> </div>
<script src="../dist/reveal.min.js"></script> <script src="../dist/reveal.min.js"></script>
<script src="qunit-2.5.0.js"></script>
<script> <script>
window.externalScriptSequence = ''; window.externalScriptSequence = '';
Reveal.addEventListener( 'ready', function() { Reveal.initialize({
dependencies: [
{ src: 'assets/external-script-a.js' },
{ src: 'assets/external-script-b.js' },
{ src: 'assets/external-script-c.js' }
]
}).then( () => {
QUnit.module( 'Dependencies' ); QUnit.module( 'Dependencies' );
@ -40,14 +45,6 @@
}); });
} ); } );
Reveal.initialize({
dependencies: [
{ src: 'assets/external-script-a.js' },
{ src: 'assets/external-script-b.js' },
{ src: 'assets/external-script-c.js' }
]
});
</script> </script>
</body> </body>

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="../dist/reveal.css"> <link rel="stylesheet" href="../dist/reveal.css">
<link rel="stylesheet" href="qunit-2.5.0.css"> <link rel="stylesheet" href="qunit-2.5.0.css">
<script src="qunit-2.5.0.js"></script>
</head> </head>
<body style="overflow: auto;"> <body style="overflow: auto;">
@ -38,10 +39,8 @@
</div> </div>
<script src="../dist/reveal.min.js"></script> <script src="../dist/reveal.min.js"></script>
<script src="qunit-2.5.0.js"></script>
<script> <script>
Reveal.addEventListener( 'ready', function() { Reveal.initialize().then( () => {
QUnit.module( 'Grid Navigation' ); QUnit.module( 'Grid Navigation' );
@ -66,8 +65,6 @@
}); });
} ); } );
Reveal.initialize();
</script> </script>
</body> </body>

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="../dist/reveal.css"> <link rel="stylesheet" href="../dist/reveal.css">
<link rel="stylesheet" href="qunit-2.5.0.css"> <link rel="stylesheet" href="qunit-2.5.0.css">
<script src="qunit-2.5.0.js"></script>
</head> </head>
<body style="overflow: auto;"> <body style="overflow: auto;">
@ -31,12 +32,9 @@
</div> </div>
<script src="../dist/reveal.min.js"></script> <script src="../dist/reveal.min.js"></script>
<script src="qunit-2.5.0.js"></script>
<script> <script>
Reveal.initialize({ viewDistance: 3 }).then( () => {
Reveal.addEventListener( 'ready', function() {
function getIframe( index ) { function getIframe( index ) {
return document.querySelectorAll( '.slide-background' )[index].querySelector( 'iframe' ); return document.querySelectorAll( '.slide-background' )[index].querySelector( 'iframe' );
@ -94,10 +92,6 @@
}); });
} ); } );
Reveal.initialize({
viewDistance: 3
});
</script> </script>
</body> </body>

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="../dist/reveal.css"> <link rel="stylesheet" href="../dist/reveal.css">
<link rel="stylesheet" href="qunit-2.5.0.css"> <link rel="stylesheet" href="qunit-2.5.0.css">
<script src="qunit-2.5.0.js"></script>
</head> </head>
<body style="overflow: auto;"> <body style="overflow: auto;">
@ -31,12 +32,9 @@
</div> </div>
<script src="../dist/reveal.min.js"></script> <script src="../dist/reveal.min.js"></script>
<script src="qunit-2.5.0.js"></script>
<script> <script>
Reveal.initialize({ viewDistance: 2 }).then( () => {
Reveal.addEventListener( 'ready', function() {
var defaultIframe = document.querySelector( '.default-iframe' ), var defaultIframe = document.querySelector( '.default-iframe' ),
preloadIframe = document.querySelector( '.preload-iframe' ); preloadIframe = document.querySelector( '.preload-iframe' );
@ -98,10 +96,6 @@
}); });
} ); } );
Reveal.initialize({
viewDistance: 2
});
</script> </script>
</body> </body>

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="../dist/reveal.css"> <link rel="stylesheet" href="../dist/reveal.css">
<link rel="stylesheet" href="qunit-2.5.0.css"> <link rel="stylesheet" href="qunit-2.5.0.css">
<script src="qunit-2.5.0.js"></script>
</head> </head>
<body style="overflow: auto;"> <body style="overflow: auto;">
@ -122,11 +123,55 @@
</div> </div>
<script src="../dist/reveal.min.js"></script> <script src="../dist/reveal.min.js"></script>
<script src="../plugin/markdown/marked.js"></script> <script>
<script src="../plugin/markdown/markdown.js"></script> Reveal.initialize({
<script src="qunit-2.5.0.js"></script> dependencies: [
{ src: '../plugin/markdown/marked.js' },
{ src: '../plugin/markdown/markdown.js' },
]
}).then( function() {
<script src="test-markdown-element-attributes.js"></script> QUnit.module( 'Markdown' );
QUnit.test( 'Vertical separator', function( assert ) {
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 4, 'found four slides' );
});
QUnit.test( 'Attributes on element header in vertical slides', function( assert ) {
assert.strictEqual( document.querySelectorAll( '.reveal .slides section>section h2.fragment.fade-out' ).length, 1, 'found one vertical slide with class fragment.fade-out on header' );
assert.strictEqual( document.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( document.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( document.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( document.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( document.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( document.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( document.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( document.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' );
});
} );
</script>
</body> </body>
</html> </html>

View File

@ -1,44 +0,0 @@
Reveal.addEventListener( 'ready', function() {
QUnit.module( 'Markdown' );
QUnit.test( 'Vertical separator', function( assert ) {
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 4, 'found four slides' );
});
QUnit.test( 'Attributes on element header in vertical slides', function( assert ) {
assert.strictEqual( document.querySelectorAll( '.reveal .slides section>section h2.fragment.fade-out' ).length, 1, 'found one vertical slide with class fragment.fade-out on header' );
assert.strictEqual( document.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( document.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( document.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( document.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( document.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( document.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( document.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( document.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' );
});
} );
Reveal.initialize();

View File

@ -18,20 +18,34 @@
<div class="reveal" style="display: none;"> <div class="reveal" style="display: none;">
<div class="slides"> <div class="slides">
<!-- <section data-markdown="simple.md" data-separator="^\r?\n\r?\n\r?\n" data-separator-vertical="^\r?\n\r?\n"></section> --> <section data-markdown="simple.md" data-separator="^\r?\n\r?\n\r?\n" data-separator-vertical="^\r?\n\r?\n"></section>
</div> </div>
</div> </div>
<script src="../dist/reveal.min.js"></script>
<script src="../plugin/highlight/highlight.js"></script>
<script src="../plugin/markdown/marked.js"></script>
<script src="../plugin/markdown/markdown.js"></script>
<script src="qunit-2.5.0.js"></script> <script src="qunit-2.5.0.js"></script>
<script src="../dist/reveal.min.js"></script>
<!-- <script src="test-markdown-external.js"></script> --> <script>
Reveal.initialize({
dependencies: [
{ src: '../plugin/markdown/marked.js' },
{ src: '../plugin/markdown/markdown.js' },
]
}).then( function() {
<!-- Test disabled 28/2/2019 by Hakim Markdown plugin needs to be updated to load extenal files asycnhronously --> QUnit.module( 'Markdown' );
QUnit.test( 'Vertical separator', function( assert ) {
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 2, 'found two slides' );
});
QUnit.test( 'Horizontal separator', function( assert ) {
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section' ).length, 2, 'found two slides' );
});
} );
</script>
</body> </body>
</html> </html>

View File

@ -1,20 +0,0 @@
Reveal.addEventListener( 'ready', function() {
QUnit.module( 'Markdown' );
QUnit.test( 'Vertical separator', function( assert ) {
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 2, 'found two slides' );
});
QUnit.test( 'Horizontal separator', function( assert ) {
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section' ).length, 2, 'found two slides' );
});
QUnit.test( 'Language highlighter', function( assert ) {
assert.strictEqual( document.querySelectorAll( '.hljs-keyword' ).length, 1, 'got rendered highlight tag.' );
assert.strictEqual( document.querySelector( '.hljs-keyword' ).innerHTML, 'var', 'the same keyword: var.' );
});
} );
Reveal.initialize();

View File

@ -31,10 +31,37 @@
</div> </div>
<script src="../dist/reveal.min.js"></script>
<script src="qunit-2.5.0.js"></script> <script src="qunit-2.5.0.js"></script>
<script src="../dist/reveal.min.js"></script>
<script src="test-markdown-options.js"></script> <script>
Reveal.initialize({
dependencies: [
{ src: '../plugin/markdown/marked.js' },
// Test loading JS files with query strings
{ src: '../plugin/markdown/markdown.js?query=string' },
],
markdown: {
smartypants: true
}
}).then( function() {
QUnit.module( 'Markdown' );
QUnit.test( 'Options are set', function( assert ) {
assert.strictEqual( marked.defaults.smartypants, true );
});
QUnit.test( 'Smart quotes are activated', function( assert ) {
var text = document.querySelector( '.reveal .slides>section>p' ).textContent;
assert.strictEqual( /['"]/.test( text ), false );
assert.strictEqual( /[“”‘’]/.test( text ), true );
});
} );
</script>
</body> </body>
</html> </html>

View File

@ -1,27 +0,0 @@
Reveal.addEventListener( 'ready', function() {
QUnit.module( 'Markdown' );
QUnit.test( 'Options are set', function( assert ) {
assert.strictEqual( marked.defaults.smartypants, true );
});
QUnit.test( 'Smart quotes are activated', function( assert ) {
var text = document.querySelector( '.reveal .slides>section>p' ).textContent;
assert.strictEqual( /['"]/.test( text ), false );
assert.strictEqual( /[“”‘’]/.test( text ), true );
});
} );
Reveal.initialize({
dependencies: [
{ src: '../plugin/markdown/marked.js' },
// Test loading JS files with query strings
{ src: '../plugin/markdown/markdown.js?query=string' },
],
markdown: {
smartypants: true
}
});

View File

@ -116,12 +116,58 @@
</div> </div>
<script src="../dist/reveal.min.js"></script>
<script src="../plugin/markdown/marked.js"></script>
<script src="../plugin/markdown/markdown.js"></script>
<script src="qunit-2.5.0.js"></script> <script src="qunit-2.5.0.js"></script>
<script src="../dist/reveal.min.js"></script>
<script src="test-markdown-slide-attributes.js"></script> <script>
Reveal.initialize({
dependencies: [
{ src: '../plugin/markdown/marked.js' },
{ src: '../plugin/markdown/markdown.js' },
]
}).then( function() {
QUnit.module( 'Markdown' );
QUnit.test( 'Vertical separator', function( assert ) {
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 6, 'found six vertical slides' );
});
QUnit.test( 'Id on slide', function( assert ) {
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section#slide2' ).length, 1, 'found one slide with id slide2' );
assert.strictEqual( document.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( document.querySelectorAll( '.reveal .slides>section>section[data-background="#A0C66B"]' ).length, 1, 'found one vertical slide with data-background="#A0C66B"' );
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#ff0000"]' ).length, 1, 'found one vertical slide with data-background="#ff0000"' );
assert.strictEqual( document.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( document.querySelectorAll( '.reveal .slides>section>section[data-transition="zoom"]' ).length, 1, 'found one vertical slide with data-transition="zoom"' );
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="fade"]' ).length, 1, 'found one vertical slide with data-transition="fade"' );
assert.strictEqual( document.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( document.querySelectorAll( '.reveal .slides>section>section[data-background="#A7C66B"]' ).length, 1, 'found one vertical slide with data-background="#A0C66B"' );
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#f70000"]' ).length, 1, 'found one vertical slide with data-background="#ff0000"' );
assert.strictEqual( document.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( document.querySelectorAll( '.reveal .slides>section>section[data-transition="concave"]' ).length, 1, 'found one vertical slide with data-transition="zoom"' );
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="page"]' ).length, 1, 'found one vertical slide with data-transition="fade"' );
assert.strictEqual( document.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( document.querySelectorAll( '.reveal .slides>section[data-background="#ff0000"]' ).length, 3, 'found three horizontal slides with data-background="#ff0000"' );
});
} );
</script>
</body> </body>
</html> </html>

View File

@ -1,44 +0,0 @@
Reveal.addEventListener( 'ready', function() {
QUnit.module( 'Markdown' );
QUnit.test( 'Vertical separator', function( assert ) {
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 6, 'found six vertical slides' );
});
QUnit.test( 'Id on slide', function( assert ) {
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section#slide2' ).length, 1, 'found one slide with id slide2' );
assert.strictEqual( document.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( document.querySelectorAll( '.reveal .slides>section>section[data-background="#A0C66B"]' ).length, 1, 'found one vertical slide with data-background="#A0C66B"' );
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#ff0000"]' ).length, 1, 'found one vertical slide with data-background="#ff0000"' );
assert.strictEqual( document.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( document.querySelectorAll( '.reveal .slides>section>section[data-transition="zoom"]' ).length, 1, 'found one vertical slide with data-transition="zoom"' );
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="fade"]' ).length, 1, 'found one vertical slide with data-transition="fade"' );
assert.strictEqual( document.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( document.querySelectorAll( '.reveal .slides>section>section[data-background="#A7C66B"]' ).length, 1, 'found one vertical slide with data-background="#A0C66B"' );
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-background="#f70000"]' ).length, 1, 'found one vertical slide with data-background="#ff0000"' );
assert.strictEqual( document.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( document.querySelectorAll( '.reveal .slides>section>section[data-transition="concave"]' ).length, 1, 'found one vertical slide with data-transition="zoom"' );
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section[data-transition="page"]' ).length, 1, 'found one vertical slide with data-transition="fade"' );
assert.strictEqual( document.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( document.querySelectorAll( '.reveal .slides>section[data-background="#ff0000"]' ).length, 3, 'found three horizontal slides with data-background="#ff0000"' );
});
} );
Reveal.initialize();

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="../dist/reveal.css"> <link rel="stylesheet" href="../dist/reveal.css">
<link rel="stylesheet" href="qunit-2.5.0.css"> <link rel="stylesheet" href="qunit-2.5.0.css">
<script src="qunit-2.5.0.js"></script>
</head> </head>
<body style="overflow: auto;"> <body style="overflow: auto;">
@ -41,11 +42,22 @@
</div> </div>
<script src="../dist/reveal.min.js"></script> <script src="../dist/reveal.min.js"></script>
<script src="../plugin/markdown/marked.js"></script> <script>
<script src="../plugin/markdown/markdown.js"></script> Reveal.initialize({
<script src="qunit-2.5.0.js"></script> dependencies: [
{ src: '../plugin/markdown/marked.js' },
{ src: '../plugin/markdown/markdown.js' },
]
}).then( function() {
<script src="test-markdown.js"></script> QUnit.module( 'Markdown' );
QUnit.test( 'Vertical separator', function( assert ) {
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 2, 'found two slides' );
});
} );
</script>
</body> </body>
</html> </html>

View File

@ -1,11 +0,0 @@
Reveal.addEventListener( 'ready', function() {
QUnit.module( 'Markdown' );
QUnit.test( 'Vertical separator', function( assert ) {
assert.strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 2, 'found two slides' );
});
} );
Reveal.initialize();

View File

@ -9,6 +9,7 @@
<link rel="stylesheet" href="../dist/reveal.css"> <link rel="stylesheet" href="../dist/reveal.css">
<link rel="stylesheet" href="../css/print/pdf.css"> <link rel="stylesheet" href="../css/print/pdf.css">
<link rel="stylesheet" href="qunit-2.5.0.css"> <link rel="stylesheet" href="qunit-2.5.0.css">
<script src="qunit-2.5.0.js"></script>
</head> </head>
<body style="overflow: auto;"> <body style="overflow: auto;">
@ -74,9 +75,19 @@
</div> </div>
<script src="../dist/reveal.min.js"></script> <script src="../dist/reveal.min.js"></script>
<script src="qunit-2.5.0.js"></script> <script>
Reveal.initialize({ pdf: true }).then( function() {
<script src="test-pdf.js"></script> // 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> </body>
</html> </html>

View File

@ -1,12 +0,0 @@
Reveal.addEventListener( 'ready', function() {
// 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' );
});
} );
Reveal.initialize({ pdf: true });

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="../dist/reveal.css"> <link rel="stylesheet" href="../dist/reveal.css">
<link rel="stylesheet" href="qunit-2.5.0.css"> <link rel="stylesheet" href="qunit-2.5.0.css">
<script src="qunit-2.5.0.js"></script>
</head> </head>
<body style="overflow: auto;"> <body style="overflow: auto;">
@ -26,8 +27,6 @@
</div> </div>
<script src="../dist/reveal.min.js"></script> <script src="../dist/reveal.min.js"></script>
<script src="qunit-2.5.0.js"></script>
<script> <script>
QUnit.module( 'Plugins' ); QUnit.module( 'Plugins' );
@ -59,16 +58,18 @@
var PluginE = {}; var PluginE = {};
Reveal.registerPlugin( 'PluginA', PluginA ); var reveal = new Reveal();
Reveal.registerPlugin( 'PluginB', PluginB );
Reveal.registerPlugin( 'PluginC', PluginC );
Reveal.initialize(); reveal.registerPlugin( 'PluginA', PluginA );
reveal.registerPlugin( 'PluginB', PluginB );
reveal.registerPlugin( 'PluginC', PluginC );
reveal.initialize();
QUnit.test( 'Can initialize synchronously', function( assert ) { QUnit.test( 'Can initialize synchronously', function( assert ) {
assert.strictEqual( initCounter['PluginB'], 1 ); assert.strictEqual( initCounter['PluginB'], 1 );
Reveal.registerPlugin( 'PluginB', PluginB ); reveal.registerPlugin( 'PluginB', PluginB );
assert.strictEqual( initCounter['PluginB'], 1, 'prevents duplicate registration' ); assert.strictEqual( initCounter['PluginB'], 1, 'prevents duplicate registration' );
}); });
@ -79,25 +80,25 @@
assert.strictEqual( initCounter['PluginC'], 0, 'async plugin not immediately initialized' ); assert.strictEqual( initCounter['PluginC'], 0, 'async plugin not immediately initialized' );
Reveal.addEventListener( 'ready', function() { reveal.addEventListener( 'ready', function() {
assert.strictEqual( initCounter['PluginC'], 1, 'finsihed initializing when reveal.js dispatches "ready"' ); assert.strictEqual( initCounter['PluginC'], 1, 'finsihed initializing when reveal.js dispatches "ready"' );
done(); done();
Reveal.registerPlugin( 'PluginD', PluginD ); reveal.registerPlugin( 'PluginD', PluginD );
assert.strictEqual( initCounter['PluginD'], 1, 'plugin registered after reveal.js is ready still initiailizes' ); assert.strictEqual( initCounter['PluginD'], 1, 'plugin registered after reveal.js is ready still initiailizes' );
done(); done();
}); });
} ); } );
QUnit.test( 'Can check if plugin is registered', function( assert ) { QUnit.test( 'Can check if plugin is registered', function( assert ) {
assert.strictEqual( Reveal.hasPlugin( 'PluginA' ), true ); assert.strictEqual( reveal.hasPlugin( 'PluginA' ), true );
assert.strictEqual( Reveal.hasPlugin( 'PluginE' ), false ); assert.strictEqual( reveal.hasPlugin( 'PluginE' ), false );
Reveal.registerPlugin( 'PluginE', PluginE ); reveal.registerPlugin( 'PluginE', PluginE );
assert.strictEqual( Reveal.hasPlugin( 'PluginE' ), true ); assert.strictEqual( reveal.hasPlugin( 'PluginE' ), true );
} ); } );
QUnit.test( 'Can retrieve plugin instance', function( assert ) { QUnit.test( 'Can retrieve plugin instance', function( assert ) {
assert.strictEqual( Reveal.getPlugin( 'PluginB' ), PluginB ); assert.strictEqual( reveal.getPlugin( 'PluginB' ), PluginB );
} ); } );
</script> </script>

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="../dist/reveal.css"> <link rel="stylesheet" href="../dist/reveal.css">
<link rel="stylesheet" href="qunit-2.5.0.css"> <link rel="stylesheet" href="qunit-2.5.0.css">
<script src="qunit-2.5.0.js"></script>
</head> </head>
<body style="overflow: auto;"> <body style="overflow: auto;">
@ -36,12 +37,10 @@
</div> </div>
<script src="../dist/reveal.min.js"></script> <script src="../dist/reveal.min.js"></script>
<script src="qunit-2.5.0.js"></script>
<script> <script>
Reveal.addEventListener( 'ready', function() { Reveal.initialize().then( function() {
QUnit.module( 'State' ); QUnit.module( 'State' );
@ -131,8 +130,6 @@
}); });
} ); } );
Reveal.initialize();
</script> </script>
</body> </body>

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="../dist/reveal.css"> <link rel="stylesheet" href="../dist/reveal.css">
<link rel="stylesheet" href="qunit-2.5.0.css"> <link rel="stylesheet" href="qunit-2.5.0.css">
<script src="qunit-2.5.0.js"></script>
</head> </head>
<body style="overflow: auto;"> <body style="overflow: auto;">
@ -77,8 +78,6 @@
</div> </div>
<script src="../dist/reveal.min.js"></script> <script src="../dist/reveal.min.js"></script>
<script src="qunit-2.5.0.js"></script>
<script src="test.js"></script> <script src="test.js"></script>
</body> </body>

View File

@ -7,7 +7,7 @@
// 3 - Two fragments with same data-fragment-index // 3 - Two fragments with same data-fragment-index
// 4 // 4
Reveal.addEventListener( 'ready', function() { Reveal.initialize().then( function() {
// --------------------------------------------------------------- // ---------------------------------------------------------------
// DOM TESTS // DOM TESTS
@ -610,5 +610,3 @@ Reveal.addEventListener( 'ready', function() {
}); });
} ); } );
Reveal.initialize();