mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-25 16:05:39 +00:00
ae44042cbf
Change-Id: Ic0a47bd468532824e8648c3f6371cc403896603c
24 lines
536 B
JavaScript
24 lines
536 B
JavaScript
import wait from '../../src/wait';
|
|
|
|
QUnit.module( 'ext.popups/wait' );
|
|
|
|
QUnit.test( 'it should resolve after waiting', function ( assert ) {
|
|
assert.expect( 1, 'All assertions are executed.' );
|
|
|
|
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;
|
|
} );
|
|
} );
|