[tests][helpers] add Promise.defer() helper
This commit is contained in:
parent
6356360210
commit
9112d4beff
|
@ -93,6 +93,25 @@ console.log = (...args) => {
|
||||||
return originalLog(...args);
|
return originalLog(...args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Old style deferred promise shim - for niceness
|
||||||
|
*
|
||||||
|
* @returns {{resolve: null, reject: null}}
|
||||||
|
*/
|
||||||
|
Promise.defer = function defer() {
|
||||||
|
const deferred = {
|
||||||
|
resolve: null,
|
||||||
|
reject: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
deferred.promise = new Promise((resolve, reject) => {
|
||||||
|
deferred.resolve = resolve;
|
||||||
|
deferred.reject = reject;
|
||||||
|
});
|
||||||
|
|
||||||
|
return deferred;
|
||||||
|
};
|
||||||
|
|
||||||
global.TestHelpers = {
|
global.TestHelpers = {
|
||||||
functions: {
|
functions: {
|
||||||
data: require('./../functions/test-data'),
|
data: require('./../functions/test-data'),
|
||||||
|
|
Loading…
Reference in New Issue