2017-07-28 17:32:46 +00:00
|
|
|
import wait from '../../src/wait';
|
2017-02-15 19:45:13 +00:00
|
|
|
|
|
|
|
QUnit.module( 'ext.popups/wait' );
|
|
|
|
|
|
|
|
QUnit.test( 'it should resolve after waiting', function ( assert ) {
|
|
|
|
assert.expect( 1 );
|
|
|
|
|
2018-03-19 19:39:41 +00:00
|
|
|
const timeout = this.sandbox.stub( global, 'setTimeout' ).callsFake( ( callback ) => {
|
2017-02-15 19:45:13 +00:00
|
|
|
callback();
|
|
|
|
} );
|
|
|
|
|
2018-03-14 23:50:09 +00:00
|
|
|
return wait( 150 ).then( () => {
|
2017-02-15 19:45:13 +00:00
|
|
|
assert.strictEqual(
|
|
|
|
timeout.getCall( 0 ).args[ 1 ],
|
|
|
|
150,
|
|
|
|
'It waits for the given duration'
|
|
|
|
);
|
2017-08-16 18:27:35 +00:00
|
|
|
timeout.restore();
|
2018-03-14 23:50:09 +00:00
|
|
|
} ).catch( ( err ) => {
|
2017-08-22 11:28:05 +00:00
|
|
|
timeout.restore();
|
|
|
|
throw err;
|
2017-02-15 19:45:13 +00:00
|
|
|
} );
|
|
|
|
} );
|