aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2019-03-14 16:03:55 +0100
committerHakim El Hattab <hakim.elhattab@gmail.com>2019-03-14 16:03:55 +0100
commitc7db11d9cfeb7984f643af3effb1fea5865ce4cc (patch)
treedf2e76951d1fe06b088059190f9861de07b9197a
parentb180d94e0227558de766af47b37d96693a942b60 (diff)
downloadfreenode-live-2017-presentation-c7db11d9cfeb7984f643af3effb1fea5865ce4cc.tar
freenode-live-2017-presentation-c7db11d9cfeb7984f643af3effb1fea5865ce4cc.tar.gz
tests for plugins
-rw-r--r--css/reveal.scss2
-rw-r--r--test/test-plugins.html92
2 files changed, 93 insertions, 1 deletions
diff --git a/css/reveal.scss b/css/reveal.scss
index 3b4b05c..ab732a4 100644
--- a/css/reveal.scss
+++ b/css/reveal.scss
@@ -1591,7 +1591,7 @@ $controlsArrowAngleActive: 36deg;
}
.reveal .hljs[data-line-numbers]:not([data-line-numbers=""]) tr:not(.highlight-line) {
- opacity: 0.25;
+ opacity: 0.4;
}
diff --git a/test/test-plugins.html b/test/test-plugins.html
new file mode 100644
index 0000000..13e3692
--- /dev/null
+++ b/test/test-plugins.html
@@ -0,0 +1,92 @@
+<!doctype html>
+<html lang="en">
+
+ <head>
+ <meta charset="utf-8">
+
+ <title>reveal.js - Test Plugins</title>
+
+ <link rel="stylesheet" href="../css/reveal.css">
+ <link rel="stylesheet" href="qunit-2.5.0.css">
+ </head>
+
+ <body style="overflow: auto;">
+
+ <div id="qunit"></div>
+ <div id="qunit-fixture"></div>
+
+ <div class="reveal" style="display: none;">
+
+ <div class="slides">
+
+ <section>Slide content</section>
+
+ </div>
+
+ </div>
+
+ <script src="../js/reveal.js"></script>
+ <script src="qunit-2.5.0.js"></script>
+
+ <script>
+
+ QUnit.module( 'Plugins' );
+
+ var initCounter = { PluginB: 0, PluginC: 0, PluginD: 0 };
+
+ // Plugin with no init method
+ var PluginA = {};
+
+ // Plugin with init method
+ var PluginB = { init: function() {
+ initCounter['PluginB'] += 1;
+ } };
+
+ // Async plugin with init method
+ var PluginC = { init: function() {
+ return new Promise(function( resolve ) {
+ setTimeout( () => {
+ initCounter['PluginC'] += 1;
+ resolve();
+ }, 1000 );
+ });
+ } };
+
+ // Plugin initialized after reveal.js is ready
+ var PluginD = { init: function() {
+ initCounter['PluginD'] += 1;
+ } };
+
+ Reveal.registerPlugin( 'PluginA', PluginA );
+ Reveal.registerPlugin( 'PluginB', PluginB );
+ Reveal.registerPlugin( 'PluginC', PluginC );
+
+ Reveal.initialize();
+
+ QUnit.test( 'Can initialize synchronously', function( assert ) {
+ assert.strictEqual( initCounter['PluginB'], 1 );
+
+ Reveal.registerPlugin( 'PluginB', PluginB );
+
+ assert.strictEqual( initCounter['PluginB'], 1, 'prevents duplicate registration' );
+ });
+
+ QUnit.test( 'Can initialie asynchronously', function( assert ) {
+ assert.expect( 3 );
+ var done = assert.async( 2 );
+
+ assert.strictEqual( initCounter['PluginC'], 0, 'async plugin not immediately initialized' );
+
+ Reveal.addEventListener( 'ready', function() {
+ assert.strictEqual( initCounter['PluginC'], 1, 'finsihed initializing when reveal.js dispatches "ready"' );
+ done();
+
+ Reveal.registerPlugin( 'PluginD', PluginD );
+ assert.strictEqual( initCounter['PluginD'], 1, 'plugin registered after reveal.js is ready still initiailizes' );
+ done();
+ });
+ } );
+ </script>
+
+ </body>
+</html>