1
0
Fork 0

spec updates

This commit is contained in:
hakimel 2023-01-10 10:24:41 +01:00
parent 2eb6d1e71c
commit a815c7d269
15 changed files with 823 additions and 255 deletions

912
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -51,8 +51,8 @@
"gulp-zip": "^4.2.0", "gulp-zip": "^4.2.0",
"highlight.js": "^10.0.3", "highlight.js": "^10.0.3",
"marked": "^4.0.12", "marked": "^4.0.12",
"node-qunit-puppeteer": "^2.1.0", "node-qunit-puppeteer": "^2.1.2",
"qunit": "^2.17.2", "qunit": "^2.19.3",
"rollup": "^2.48.0", "rollup": "^2.48.0",
"rollup-plugin-terser": "^7.0.2", "rollup-plugin-terser": "^7.0.2",
"sass": "^1.39.2", "sass": "^1.39.2",

View File

@ -65,6 +65,7 @@
<script src="../dist/reveal.js"></script> <script src="../dist/reveal.js"></script>
<script> <script>
QUnit.config.testTimeout = 30000;
QUnit.config.reorder = false; QUnit.config.reorder = false;
const slides = Array.prototype.map.call( document.querySelectorAll( '.slides section' ), slide => { const slides = Array.prototype.map.call( document.querySelectorAll( '.slides section' ), slide => {

View File

@ -31,6 +31,7 @@
var externalScriptSequence = ''; var externalScriptSequence = '';
var scriptCount = 0; var scriptCount = 0;
QUnit.config.testTimeout = 30000;
QUnit.config.autostart = false; QUnit.config.autostart = false;
QUnit.module( 'Async Dependencies' ); QUnit.module( 'Async Dependencies' );

View File

@ -30,6 +30,10 @@
<script> <script>
window.externalScriptSequence = ''; window.externalScriptSequence = '';
QUnit.config.testTimeout = 30000;
QUnit.config.autostart = false;
QUnit.module( 'Dependencies' );
Reveal.initialize({ Reveal.initialize({
dependencies: [ dependencies: [
{ src: 'assets/external-script-a.js' }, { src: 'assets/external-script-a.js' },
@ -38,7 +42,7 @@
] ]
}).then( () => { }).then( () => {
QUnit.module( 'Dependencies' ); QUnit.start();
QUnit.test( 'Load synchronous scripts', function( assert ) { QUnit.test( 'Load synchronous scripts', function( assert ) {
assert.strictEqual( window.externalScriptSequence, 'ABC', 'Loaded and executed in order' ); assert.strictEqual( window.externalScriptSequence, 'ABC', 'Loaded and executed in order' );

View File

@ -40,9 +40,13 @@
<script src="../dist/reveal.js"></script> <script src="../dist/reveal.js"></script>
<script> <script>
QUnit.config.testTimeout = 30000;
QUnit.config.autostart = false;
QUnit.module( 'Grid Navigation' );
Reveal.initialize().then( () => { Reveal.initialize().then( () => {
QUnit.module( 'Grid Navigation' ); QUnit.start();
QUnit.test( 'Disabled', function( assert ) { QUnit.test( 'Disabled', function( assert ) {
Reveal.right(); Reveal.right();

View File

@ -34,6 +34,8 @@
<script src="../dist/reveal.js"></script> <script src="../dist/reveal.js"></script>
<script> <script>
QUnit.config.testTimeout = 30000;
Reveal.initialize({ viewDistance: 3 }).then( () => { Reveal.initialize({ viewDistance: 3 }).then( () => {
function getIframe( index ) { function getIframe( index ) {

View File

@ -34,6 +34,8 @@
<script src="../dist/reveal.js"></script> <script src="../dist/reveal.js"></script>
<script> <script>
QUnit.config.testTimeout = 30000;
Reveal.initialize({ viewDistance: 2 }).then( () => { Reveal.initialize({ viewDistance: 2 }).then( () => {
var defaultIframe = document.querySelector( '.default-iframe' ), var defaultIframe = document.querySelector( '.default-iframe' ),

View File

@ -298,6 +298,8 @@
import Markdown from '../plugin/markdown/markdown.esm.js' import Markdown from '../plugin/markdown/markdown.esm.js'
import Highlight from '../plugin/highlight/highlight.esm.js' import Highlight from '../plugin/highlight/highlight.esm.js'
QUnit.config.testTimeout = 30000;
let deck1 = new Reveal( document.querySelector( '.deck1' ), { plugins: [ Markdown ] }) let deck1 = new Reveal( document.querySelector( '.deck1' ), { plugins: [ Markdown ] })
deck1.addEventListener( 'ready', function() { deck1.addEventListener( 'ready', function() {

View File

@ -40,6 +40,7 @@
<script src="../plugin/zoom/zoom.js"></script> <script src="../plugin/zoom/zoom.js"></script>
<script> <script>
QUnit.config.testTimeout = 30000;
QUnit.module( 'Multiple reveal.js instances' ); QUnit.module( 'Multiple reveal.js instances' );
let r1 = new Reveal( document.querySelector( '.deck1 .reveal' ), { let r1 = new Reveal( document.querySelector( '.deck1 .reveal' ), {

View File

@ -41,6 +41,7 @@
import Reveal from '../dist/reveal.esm.js'; import Reveal from '../dist/reveal.esm.js';
import Zoom from '../plugin/zoom/zoom.esm.js'; import Zoom from '../plugin/zoom/zoom.esm.js';
QUnit.config.testTimeout = 30000;
QUnit.module( 'Multiple reveal.js instances' ); QUnit.module( 'Multiple reveal.js instances' );
let r1 = new Reveal( document.querySelector( '.deck1 .reveal' ), { let r1 = new Reveal( document.querySelector( '.deck1 .reveal' ), {

View File

@ -75,8 +75,13 @@
<script src="../dist/reveal.js"></script> <script src="../dist/reveal.js"></script>
<script> <script>
QUnit.config.testTimeout = 30000;
QUnit.config.autostart = false;
Reveal.initialize({ pdf: true }).then( function() { Reveal.initialize({ pdf: true }).then( function() {
QUnit.start();
// Only one test for now, we're mainly ensuring that there // Only one test for now, we're mainly ensuring that there
// are no execution errors when running PDF mode // are no execution errors when running PDF mode

View File

@ -29,6 +29,7 @@
<script src="../dist/reveal.js"></script> <script src="../dist/reveal.js"></script>
<script> <script>
QUnit.config.testTimeout = 30000;
QUnit.module( 'Plugins' ); QUnit.module( 'Plugins' );
var initCounter = { PluginB: 0, PluginC: 0, PluginD: 0 }; var initCounter = { PluginB: 0, PluginC: 0, PluginD: 0 };

View File

@ -39,97 +39,95 @@
<script src="../dist/reveal.js"></script> <script src="../dist/reveal.js"></script>
<script> <script>
Reveal.initialize().then( function() { Reveal.initialize();
console.log(Reveal);
QUnit.module( 'State' ); QUnit.module( 'State' );
QUnit.test( 'Fire events when changing slide', function( assert ) { QUnit.test( 'Fire events when changing slide', function( assert ) {
assert.expect( 2 ); assert.expect( 2 );
var state1 = assert.async(); var state1 = assert.async();
var state2 = assert.async(); var state2 = assert.async();
var _onState1 = function( event ) { var _onState1 = function( event ) {
assert.ok( true, 'state1 fired' ); assert.ok( true, 'state1 fired' );
state1(); state1();
} }
var _onState2 = function( event ) { var _onState2 = function( event ) {
assert.ok( true, 'state2 fired' ); assert.ok( true, 'state2 fired' );
state2(); state2();
} }
Reveal.on( 'state1', _onState1 ); Reveal.on( 'state1', _onState1 );
Reveal.on( 'state2', _onState2 ); Reveal.on( 'state2', _onState2 );
Reveal.slide( 1 ); Reveal.slide( 1 );
Reveal.slide( 3 ); Reveal.slide( 3 );
Reveal.off( 'state1', _onState1 ); Reveal.off( 'state1', _onState1 );
Reveal.off( 'state2', _onState2 ); Reveal.off( 'state2', _onState2 );
}); });
QUnit.test( 'Fire state events for vertical slides', function( assert ) { QUnit.test( 'Fire state events for vertical slides', function( assert ) {
assert.expect( 2 ); assert.expect( 2 );
var done = assert.async( 2 ); var done = assert.async( 2 );
var _onState1 = function( event ) { var _onState1 = function( event ) {
assert.ok( true, 'state1 fired' ); assert.ok( true, 'state1 fired' );
done(); done();
} }
var _onState3 = function( event ) { var _onState3 = function( event ) {
assert.ok( true, 'state3 fired' ); assert.ok( true, 'state3 fired' );
done(); done();
} }
Reveal.on( 'state1', _onState1 ); Reveal.on( 'state1', _onState1 );
Reveal.on( 'state3', _onState3 ); Reveal.on( 'state3', _onState3 );
Reveal.slide( 0 ); Reveal.slide( 0 );
Reveal.slide( 4, 1 ); Reveal.slide( 4, 1 );
Reveal.slide( 4, 2 ); Reveal.slide( 4, 2 );
Reveal.off( 'state1', _onState1 ); Reveal.off( 'state1', _onState1 );
Reveal.off( 'state3', _onState3 ); Reveal.off( 'state3', _onState3 );
}); });
QUnit.test( 'No events if state remains unchanged', function( assert ) { QUnit.test( 'No events if state remains unchanged', function( assert ) {
var stateChanges = 0; var stateChanges = 0;
var _onEvent = function( event ) { var _onEvent = function( event ) {
stateChanges += 1; stateChanges += 1;
} }
Reveal.on( 'state1', _onEvent ); Reveal.on( 'state1', _onEvent );
Reveal.slide( 0 ); // no state Reveal.slide( 0 ); // no state
Reveal.slide( 1 ); // state1 Reveal.slide( 1 ); // state1
Reveal.slide( 2 ); // state1 Reveal.slide( 2 ); // state1
Reveal.prev(); // state1 Reveal.prev(); // state1
Reveal.next(); // state1 Reveal.next(); // state1
Reveal.slide( 4, 1 ); // state1 Reveal.slide( 4, 1 ); // state1
Reveal.slide( 0 ); // no state Reveal.slide( 0 ); // no state
Reveal.off( 'state1', _onEvent ); Reveal.off( 'state1', _onEvent );
assert.strictEqual( stateChanges, 1, 'no event was fired when going to slide with same state' ); assert.strictEqual( stateChanges, 1, 'no event was fired when going to slide with same state' );
}); });
QUnit.test( 'Event order', function( assert ) { QUnit.test( 'Event order', function( assert ) {
var _onEvent = function( event ) { var _onEvent = function( event ) {
assert.ok( Reveal.getCurrentSlide() == document.querySelector( '#slide2' ), 'correct current slide immediately after state event' ); assert.ok( Reveal.getCurrentSlide() == document.querySelector( '#slide2' ), 'correct current slide immediately after state event' );
} }
Reveal.on( 'state1', _onEvent ); Reveal.on( 'state1', _onEvent );
Reveal.slide( 0 ); Reveal.slide( 0 );
Reveal.slide( 1 ); Reveal.slide( 1 );
Reveal.off( 'state1', _onEvent ); Reveal.off( 'state1', _onEvent );
}); });
} );
</script> </script>
</body> </body>

View File

@ -83,6 +83,8 @@
<script src="../dist/reveal.js"></script> <script src="../dist/reveal.js"></script>
<script> <script>
QUnit.config.testTimeout = 30000;
window.location.hash = ''; window.location.hash = '';
Reveal.configure({maxScale: 1.11}); Reveal.configure({maxScale: 1.11});