mediawiki-extensions-Popups/tests/node-qunit/wait.test.js
Jan Drewniak f4d04b95b6 Updating mw-node-qunit to v3
Fixes tests for sinon v4, which is a dependency of mw-node-qunit v3.

Bug: T180255
Change-Id: I8c7b703f81140e06546aa954f98b8766f5225ff5
2018-02-08 12:20:52 +01:00

26 lines
531 B
JavaScript

import wait from '../../src/wait';
QUnit.module( 'ext.popups/wait' );
QUnit.test( 'it should resolve after waiting', function ( assert ) {
var timeout;
assert.expect( 1 );
timeout = this.sandbox.stub( global, 'setTimeout' ).callsFake( function ( callback ) {
callback();
} );
return wait( 150 ).then( function () {
assert.strictEqual(
timeout.getCall( 0 ).args[ 1 ],
150,
'It waits for the given duration'
);
timeout.restore();
} ).catch( function ( err ) {
timeout.restore();
throw err;
} );
} );