mediawiki-extensions-Popups/tests/node-qunit/wait.test.js
joakin 30550e2670 Test: Migrate wait.test.js to node-qunit
Don't use fake timers for now because of some problems with other async
tests.

Change-Id: If48a8c7390416938d50c9c0c39539fe4a6a9a6af
2017-02-22 12:13:37 +01:00

27 lines
488 B
JavaScript

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