Allow testAsyncMulti functions to return promises.

This commit is contained in:
Ben Newman
2018-04-28 23:40:41 -04:00
parent 61506c64e2
commit d3df76b2b5

View File

@@ -139,16 +139,18 @@ testAsyncMulti = function (name, funcs) {
}, timeout);
test.extraDetails.asyncBlock = i++;
try {
func.apply(context, [test, _.bind(em.expect, em)]);
} catch (exception) {
if (em.cancel())
new Promise(resolve => {
resolve(func.apply(context, [test, _.bind(em.expect, em)]));
}).then(result => {
em.done();
}, exception => {
if (em.cancel()) {
test.exception(exception);
// Because we called test.exception, we're not to call onComplete.
}
Meteor.clearTimeout(timer);
// Because we called test.exception, we're not to call onComplete.
return;
}
em.done();
});
}
};