mediawiki-extensions-Popups/tests/node-qunit/wait.test.js
joakin 4d8364a999 Hygiene: Use promises A/A+ everywhere
Remove usages of deprecated methods like .done which make jquery
promises fall back to non-standard behavior

Additional changes:
* Rename var promise to a more descriptive name in tests

Bug: T173819
Change-Id: I7b041d0a7a8c42a8eac947295d265e898085c60a
2017-08-22 13:36:00 +02:00

26 lines
519 B
JavaScript

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