* Merges #1808 from @DCtheTall
* Fixes #1803
This commit is contained in:
Steve Gravrock
2020-04-11 11:17:03 -07:00
4 changed files with 104 additions and 0 deletions

View File

@@ -4054,6 +4054,32 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
return GlobalErrors;
};
getJasmineRequireObj().toBePending = function(j$) {
/**
* Expect a promise to be pending, ie. the promise is neither resolved nor rejected.
* @function
* @async
* @name async-matchers#toBePending
* @since 3.5.1 (should this be the next version or the version when it was added?)
* @example
* await expectAsync(aPromise).toBePending();
*/
return function toBePending() {
return {
compare: function(actual) {
if (!j$.isPromiseLike(actual)) {
throw new Error('Expected toBePending to be called on a promise.');
}
var want = {};
return Promise.race([actual, Promise.resolve(want)]).then(
function(got) { return {pass: want === got}; },
function() { return {pass: false}; }
);
}
};
};
};
getJasmineRequireObj().toBeRejected = function(j$) {
/**
* Expect a promise to be rejected.
@@ -5087,6 +5113,7 @@ getJasmineRequireObj().ObjectPath = function(j$) {
getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$) {
var availableMatchers = [
'toBePending',
'toBeResolved',
'toBeRejected',
'toBeResolvedTo',