Refer to MatchersUtil instances as matchersUtil, not util
This commit is contained in:
@@ -341,7 +341,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
runnableResources[spec.id].customEqualityTesters;
|
||||
|
||||
return j$.Expectation.factory({
|
||||
util: makeMatchersUtil(),
|
||||
matchersUtil: makeMatchersUtil(),
|
||||
customEqualityTesters: customEqualityTesters,
|
||||
customMatchers: runnableResources[spec.id].customMatchers,
|
||||
actual: actual,
|
||||
@@ -355,7 +355,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
|
||||
var asyncExpectationFactory = function(actual, spec) {
|
||||
return j$.Expectation.asyncFactory({
|
||||
util: makeMatchersUtil(),
|
||||
matchersUtil: makeMatchersUtil(),
|
||||
customEqualityTesters: runnableResources[spec.id].customEqualityTesters,
|
||||
customAsyncMatchers: runnableResources[spec.id].customAsyncMatchers,
|
||||
actual: actual,
|
||||
|
||||
@@ -129,7 +129,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
||||
return result;
|
||||
}
|
||||
|
||||
function negatedFailureMessage(result, matcherName, args, util) {
|
||||
function negatedFailureMessage(result, matcherName, args, matchersUtil) {
|
||||
if (result.message) {
|
||||
if (j$.isFunction_(result.message)) {
|
||||
return result.message();
|
||||
@@ -141,7 +141,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
||||
args = args.slice();
|
||||
args.unshift(true);
|
||||
args.unshift(matcherName);
|
||||
return util.buildFailureMessage.apply(util, args);
|
||||
return matchersUtil.buildFailureMessage.apply(matchersUtil, args);
|
||||
}
|
||||
|
||||
function negate(result) {
|
||||
|
||||
@@ -16,7 +16,7 @@ getJasmineRequireObj().ExpectationFilterChain = function() {
|
||||
result,
|
||||
matcherName,
|
||||
args,
|
||||
util
|
||||
matchersUtil
|
||||
) {
|
||||
return this.callFirst_('buildFailureMessage', arguments).result;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
getJasmineRequireObj().Expector = function(j$) {
|
||||
function Expector(options) {
|
||||
this.util = options.util || { buildFailureMessage: function() {} };
|
||||
this.matchersUtil = options.matchersUtil || {
|
||||
buildFailureMessage: function() {}
|
||||
};
|
||||
this.customEqualityTesters = options.customEqualityTesters || [];
|
||||
this.actual = options.actual;
|
||||
this.addExpectationResult = options.addExpectationResult || function() {};
|
||||
@@ -18,7 +20,7 @@ getJasmineRequireObj().Expector = function(j$) {
|
||||
|
||||
this.args.unshift(this.actual);
|
||||
|
||||
var matcher = matcherFactory(this.util, this.customEqualityTesters);
|
||||
var matcher = matcherFactory(this.matchersUtil, this.customEqualityTesters);
|
||||
var comparisonFunc = this.filters.selectComparisonFunc(matcher);
|
||||
return comparisonFunc || matcher.compare;
|
||||
};
|
||||
@@ -34,7 +36,7 @@ getJasmineRequireObj().Expector = function(j$) {
|
||||
result,
|
||||
this.matcherName,
|
||||
this.args,
|
||||
this.util,
|
||||
this.matchersUtil,
|
||||
defaultMessage
|
||||
);
|
||||
return this.filters.modifyFailureMessage(msg || defaultMessage());
|
||||
@@ -44,7 +46,10 @@ getJasmineRequireObj().Expector = function(j$) {
|
||||
var args = self.args.slice();
|
||||
args.unshift(false);
|
||||
args.unshift(self.matcherName);
|
||||
return self.util.buildFailureMessage.apply(self.util, args);
|
||||
return self.matchersUtil.buildFailureMessage.apply(
|
||||
self.matchersUtil,
|
||||
args
|
||||
);
|
||||
} else if (j$.isFunction_(result.message)) {
|
||||
return result.message();
|
||||
} else {
|
||||
|
||||
@@ -10,7 +10,7 @@ getJasmineRequireObj().toBeRejected = function(j$) {
|
||||
* @example
|
||||
* return expectAsync(aPromise).toBeRejected();
|
||||
*/
|
||||
return function toBeRejected(util) {
|
||||
return function toBeRejected() {
|
||||
return {
|
||||
compare: function(actual) {
|
||||
if (!j$.isPromiseLike(actual)) {
|
||||
|
||||
@@ -10,7 +10,7 @@ getJasmineRequireObj().toBeResolved = function(j$) {
|
||||
* @example
|
||||
* return expectAsync(aPromise).toBeResolved();
|
||||
*/
|
||||
return function toBeResolved(util) {
|
||||
return function toBeResolved() {
|
||||
return {
|
||||
compare: function(actual) {
|
||||
if (!j$.isPromiseLike(actual)) {
|
||||
|
||||
@@ -8,7 +8,7 @@ getJasmineRequireObj().toBe = function(j$) {
|
||||
* @example
|
||||
* expect(thing).toBe(realThing);
|
||||
*/
|
||||
function toBe(util) {
|
||||
function toBe(matchersUtil) {
|
||||
var tip = ' Tip: To check for deep equality, use .toEqual() instead of .toBe().';
|
||||
|
||||
return {
|
||||
@@ -18,7 +18,7 @@ getJasmineRequireObj().toBe = function(j$) {
|
||||
};
|
||||
|
||||
if (typeof expected === 'object') {
|
||||
result.message = util.buildFailureMessage('toBe', result.pass, actual, expected) + tip;
|
||||
result.message = matchersUtil.buildFailureMessage('toBe', result.pass, actual, expected) + tip;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -9,12 +9,12 @@ getJasmineRequireObj().toContain = function() {
|
||||
* expect(array).toContain(anElement);
|
||||
* expect(string).toContain(substring);
|
||||
*/
|
||||
function toContain(util) {
|
||||
function toContain(matchersUtil) {
|
||||
return {
|
||||
compare: function(actual, expected) {
|
||||
|
||||
return {
|
||||
pass: util.contains(actual, expected)
|
||||
pass: matchersUtil.contains(actual, expected)
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,15 +8,15 @@ getJasmineRequireObj().toEqual = function(j$) {
|
||||
* @example
|
||||
* expect(bigObject).toEqual({"foo": ['bar', 'baz']});
|
||||
*/
|
||||
function toEqual(util) {
|
||||
function toEqual(matchersUtil) {
|
||||
return {
|
||||
compare: function(actual, expected) {
|
||||
var result = {
|
||||
pass: false
|
||||
},
|
||||
diffBuilder = j$.DiffBuilder({prettyPrinter: util.pp});
|
||||
diffBuilder = j$.DiffBuilder({prettyPrinter: matchersUtil.pp});
|
||||
|
||||
result.pass = util.equals(actual, expected, diffBuilder);
|
||||
result.pass = matchersUtil.equals(actual, expected, diffBuilder);
|
||||
|
||||
// TODO: only set error message if test fails
|
||||
result.message = diffBuilder.getMessage();
|
||||
|
||||
Reference in New Issue
Block a user