[tests][helpers] add Promise.defer() helper

This commit is contained in:
Salakar 2018-05-13 18:29:34 +01:00
parent 6356360210
commit 9112d4beff
1 changed files with 19 additions and 0 deletions

View File

@ -93,6 +93,25 @@ console.log = (...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 = {
functions: {
data: require('./../functions/test-data'),