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 ) {
|
2017-08-16 18:27:35 +00:00
|
|
|
var timeout;
|
2017-02-15 19:45:13 +00:00
|
|
|
|
|
|
|
assert.expect( 1 );
|
|
|
|
|
2018-02-08 11:15:38 +00:00
|
|
|
timeout = this.sandbox.stub( global, 'setTimeout' ).callsFake( function ( callback ) {
|
2017-02-15 19:45:13 +00:00
|
|
|
callback();
|
|
|
|
} );
|
|
|
|
|
2017-08-22 11:28:05 +00:00
|
|
|
return wait( 150 ).then( function () {
|
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();
|
2017-08-22 11:28:05 +00:00
|
|
|
} ).catch( function ( err ) {
|
|
|
|
timeout.restore();
|
|
|
|
throw err;
|
2017-02-15 19:45:13 +00:00
|
|
|
} );
|
|
|
|
} );
|