Inject a per-runable pretty printer into MatchersUtil

This will allow us to add support for custom object formatters, which
will be a per-runable resource like custom matchers, by injecting them
into the pretty-printer.
This commit is contained in:
Steve Gravrock
2019-10-08 22:57:07 -07:00
committed by Steve Gravrock
parent dec67bd535
commit 1f23f1e4d2
46 changed files with 546 additions and 401 deletions

View File

@@ -11,7 +11,7 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
* @example
* return expectAsync(aPromise).toBeResolvedTo({prop: 'value'});
*/
return function toBeResolvedTo(util) {
return function toBeResolvedTo(matchersUtil) {
return {
compare: function(actualPromise, expectedValue) {
if (!j$.isPromiseLike(actualPromise)) {
@@ -21,12 +21,12 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
function prefix(passed) {
return 'Expected a promise ' +
(passed ? 'not ' : '') +
'to be resolved to ' + j$.pp(expectedValue);
'to be resolved to ' + matchersUtil.pp(expectedValue);
}
return actualPromise.then(
function(actualValue) {
if (util.equals(actualValue, expectedValue)) {
if (matchersUtil.equals(actualValue, expectedValue)) {
return {
pass: true,
message: prefix(true) + '.'
@@ -34,7 +34,7 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
} else {
return {
pass: false,
message: prefix(false) + ' but it was resolved to ' + j$.pp(actualValue) + '.'
message: prefix(false) + ' but it was resolved to ' + matchersUtil.pp(actualValue) + '.'
};
}
},