mediawiki-extensions-Popups/tests/node-qunit/wait.test.js
Stephen Niedzielski 57762e0417 Hygiene: favor const
Bug: T165036
Change-Id: I17d374eaac6627ca6a8ba178862b2a9cff2538c0
2018-03-21 10:44:24 +00:00

24 lines
504 B
JavaScript

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