Refer to MatchersUtil instances as matchersUtil, not util
This commit is contained in:
@@ -1263,7 +1263,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,
|
||||
@@ -1277,7 +1277,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,
|
||||
@@ -3561,7 +3561,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();
|
||||
@@ -3573,7 +3573,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) {
|
||||
@@ -3645,7 +3645,7 @@ getJasmineRequireObj().ExpectationFilterChain = function() {
|
||||
result,
|
||||
matcherName,
|
||||
args,
|
||||
util
|
||||
matchersUtil
|
||||
) {
|
||||
return this.callFirst_('buildFailureMessage', arguments).result;
|
||||
};
|
||||
@@ -3747,7 +3747,9 @@ getJasmineRequireObj().buildExpectationResult = function() {
|
||||
|
||||
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() {};
|
||||
@@ -3765,7 +3767,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;
|
||||
};
|
||||
@@ -3781,7 +3783,7 @@ getJasmineRequireObj().Expector = function(j$) {
|
||||
result,
|
||||
this.matcherName,
|
||||
this.args,
|
||||
this.util,
|
||||
this.matchersUtil,
|
||||
defaultMessage
|
||||
);
|
||||
return this.filters.modifyFailureMessage(msg || defaultMessage());
|
||||
@@ -3791,7 +3793,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 {
|
||||
@@ -3943,7 +3948,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)) {
|
||||
@@ -4120,7 +4125,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)) {
|
||||
@@ -4972,7 +4977,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 {
|
||||
@@ -4982,7 +4987,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;
|
||||
@@ -5428,12 +5433,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)
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -5452,15 +5457,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();
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('AsyncExpectation', function() {
|
||||
actual = Promise.resolve(),
|
||||
pp = jasmineUnderTest.makePrettyPrinter(),
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
util: new jasmineUnderTest.MatchersUtil({ pp: pp }),
|
||||
matchersUtil: new jasmineUnderTest.MatchersUtil({ pp: pp }),
|
||||
actual: actual,
|
||||
addExpectationResult: addExpectationResult
|
||||
});
|
||||
@@ -48,7 +48,9 @@ describe('AsyncExpectation', function() {
|
||||
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
actual = Promise.reject(),
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
util: new jasmineUnderTest.MatchersUtil({ pp: function() {} }),
|
||||
matchersUtil: new jasmineUnderTest.MatchersUtil({
|
||||
pp: function() {}
|
||||
}),
|
||||
actual: actual,
|
||||
addExpectationResult: addExpectationResult
|
||||
});
|
||||
@@ -92,7 +94,7 @@ describe('AsyncExpectation', function() {
|
||||
it('prepends the context to the generated failure message', function() {
|
||||
jasmine.getEnv().requirePromises();
|
||||
|
||||
var util = {
|
||||
var matchersUtil = {
|
||||
buildFailureMessage: function() {
|
||||
return 'failure message';
|
||||
}
|
||||
@@ -101,7 +103,7 @@ describe('AsyncExpectation', function() {
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
actual: Promise.reject('rejected'),
|
||||
addExpectationResult: addExpectationResult,
|
||||
util: util
|
||||
matchersUtil: matchersUtil
|
||||
});
|
||||
|
||||
return expectation
|
||||
@@ -120,7 +122,7 @@ describe('AsyncExpectation', function() {
|
||||
it('prepends the context to a custom failure message', function() {
|
||||
jasmine.getEnv().requirePromises();
|
||||
|
||||
var util = {
|
||||
var matchersUtil = {
|
||||
buildFailureMessage: function() {
|
||||
return 'failure message';
|
||||
},
|
||||
@@ -130,7 +132,7 @@ describe('AsyncExpectation', function() {
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
actual: Promise.reject('b'),
|
||||
addExpectationResult: addExpectationResult,
|
||||
util: util
|
||||
matchersUtil: matchersUtil
|
||||
});
|
||||
|
||||
return expectation
|
||||
@@ -151,7 +153,7 @@ describe('AsyncExpectation', function() {
|
||||
pending('should actually work, but no custom matchers for async yet');
|
||||
jasmine.getEnv().requirePromises();
|
||||
|
||||
var util = {
|
||||
var matchersUtil = {
|
||||
buildFailureMessage: function() {
|
||||
return 'failure message';
|
||||
}
|
||||
@@ -161,7 +163,7 @@ describe('AsyncExpectation', function() {
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
actual: actual,
|
||||
addExpectationResult: addExpectationResult,
|
||||
util: util
|
||||
matchersUtil: matchersUtil
|
||||
});
|
||||
|
||||
return expectation
|
||||
@@ -186,7 +188,7 @@ describe('AsyncExpectation', function() {
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
actual: actual,
|
||||
addExpectationResult: addExpectationResult,
|
||||
util: new jasmineUnderTest.MatchersUtil({ pp: pp })
|
||||
matchersUtil: new jasmineUnderTest.MatchersUtil({ pp: pp })
|
||||
});
|
||||
|
||||
return expectation
|
||||
@@ -211,7 +213,7 @@ describe('AsyncExpectation', function() {
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
actual: actual,
|
||||
addExpectationResult: addExpectationResult,
|
||||
util: new jasmineUnderTest.MatchersUtil({
|
||||
matchersUtil: new jasmineUnderTest.MatchersUtil({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
})
|
||||
});
|
||||
@@ -261,7 +263,7 @@ describe('AsyncExpectation', function() {
|
||||
matchers = {
|
||||
toFoo: matcherFactory
|
||||
},
|
||||
util = {
|
||||
matchersUtil = {
|
||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||
},
|
||||
customEqualityTesters = ['a'],
|
||||
@@ -269,7 +271,7 @@ describe('AsyncExpectation', function() {
|
||||
expectation;
|
||||
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
util: util,
|
||||
matchersUtil: matchersUtil,
|
||||
customAsyncMatchers: matchers,
|
||||
customEqualityTesters: customEqualityTesters,
|
||||
actual: 'an actual',
|
||||
@@ -278,7 +280,7 @@ describe('AsyncExpectation', function() {
|
||||
|
||||
return expectation.toFoo('hello').then(function() {
|
||||
expect(matcherFactory).toHaveBeenCalledWith(
|
||||
util,
|
||||
matchersUtil,
|
||||
customEqualityTesters
|
||||
);
|
||||
});
|
||||
@@ -297,14 +299,14 @@ describe('AsyncExpectation', function() {
|
||||
};
|
||||
}
|
||||
},
|
||||
util = {
|
||||
matchersUtil = {
|
||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation;
|
||||
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
util: util,
|
||||
matchersUtil: matchersUtil,
|
||||
customAsyncMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -327,7 +329,7 @@ describe('AsyncExpectation', function() {
|
||||
};
|
||||
}
|
||||
},
|
||||
util = {
|
||||
matchersUtil = {
|
||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
@@ -340,7 +342,7 @@ describe('AsyncExpectation', function() {
|
||||
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
customAsyncMatchers: matchers,
|
||||
util: util,
|
||||
matchersUtil: matchersUtil,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
});
|
||||
@@ -370,7 +372,7 @@ describe('AsyncExpectation', function() {
|
||||
};
|
||||
}
|
||||
},
|
||||
util = {
|
||||
matchersUtil = {
|
||||
buildFailureMessage: function() {
|
||||
return '';
|
||||
}
|
||||
@@ -385,7 +387,7 @@ describe('AsyncExpectation', function() {
|
||||
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
customAsyncMatchers: matchers,
|
||||
util: util,
|
||||
matchersUtil: matchersUtil,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
});
|
||||
@@ -541,7 +543,7 @@ describe('AsyncExpectation', function() {
|
||||
};
|
||||
}
|
||||
},
|
||||
util = {
|
||||
matchersUtil = {
|
||||
buildFailureMessage: function() {
|
||||
return 'default message';
|
||||
}
|
||||
@@ -558,7 +560,7 @@ describe('AsyncExpectation', function() {
|
||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||
customAsyncMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
util: util,
|
||||
matchersUtil: matchersUtil,
|
||||
addExpectationResult: addExpectationResult
|
||||
}).not;
|
||||
|
||||
|
||||
@@ -72,21 +72,21 @@ describe('ExpectationFilterChain', function() {
|
||||
matcherResult = { pass: false },
|
||||
matcherName = 'foo',
|
||||
args = [],
|
||||
util = {},
|
||||
matchersUtil = {},
|
||||
result;
|
||||
|
||||
result = chain.buildFailureMessage(
|
||||
matcherResult,
|
||||
matcherName,
|
||||
args,
|
||||
util
|
||||
matchersUtil
|
||||
);
|
||||
|
||||
expect(first).toHaveBeenCalledWith(
|
||||
matcherResult,
|
||||
matcherName,
|
||||
args,
|
||||
util
|
||||
matchersUtil
|
||||
);
|
||||
expect(second).not.toHaveBeenCalled();
|
||||
expect(result).toEqual('first');
|
||||
|
||||
@@ -37,7 +37,7 @@ describe('Expectation', function() {
|
||||
matchers = {
|
||||
toFoo: matcherFactory
|
||||
},
|
||||
util = {
|
||||
matchersUtil = {
|
||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||
},
|
||||
customEqualityTesters = ['a'],
|
||||
@@ -45,7 +45,7 @@ describe('Expectation', function() {
|
||||
expectation;
|
||||
|
||||
expectation = jasmineUnderTest.Expectation.factory({
|
||||
util: util,
|
||||
matchersUtil: matchersUtil,
|
||||
customMatchers: matchers,
|
||||
customEqualityTesters: customEqualityTesters,
|
||||
actual: 'an actual',
|
||||
@@ -54,7 +54,10 @@ describe('Expectation', function() {
|
||||
|
||||
expectation.toFoo('hello');
|
||||
|
||||
expect(matcherFactory).toHaveBeenCalledWith(util, customEqualityTesters);
|
||||
expect(matcherFactory).toHaveBeenCalledWith(
|
||||
matchersUtil,
|
||||
customEqualityTesters
|
||||
);
|
||||
});
|
||||
|
||||
it("wraps matchers's compare functions, passing the actual and expected", function() {
|
||||
@@ -68,14 +71,14 @@ describe('Expectation', function() {
|
||||
};
|
||||
}
|
||||
},
|
||||
util = {
|
||||
matchersUtil = {
|
||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation;
|
||||
|
||||
expectation = jasmineUnderTest.Expectation.factory({
|
||||
util: util,
|
||||
matchersUtil: matchersUtil,
|
||||
customMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
@@ -96,7 +99,7 @@ describe('Expectation', function() {
|
||||
};
|
||||
}
|
||||
},
|
||||
util = {
|
||||
matchersUtil = {
|
||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||
},
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
@@ -104,7 +107,7 @@ describe('Expectation', function() {
|
||||
|
||||
expectation = jasmineUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
util: util,
|
||||
matchersUtil: matchersUtil,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
});
|
||||
@@ -132,7 +135,7 @@ describe('Expectation', function() {
|
||||
};
|
||||
}
|
||||
},
|
||||
util = {
|
||||
matchersUtil = {
|
||||
buildFailureMessage: function() {
|
||||
return '';
|
||||
}
|
||||
@@ -142,7 +145,7 @@ describe('Expectation', function() {
|
||||
|
||||
expectation = jasmineUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
util: util,
|
||||
matchersUtil: matchersUtil,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
});
|
||||
@@ -275,7 +278,7 @@ describe('Expectation', function() {
|
||||
};
|
||||
}
|
||||
},
|
||||
util = {
|
||||
matchersUtil = {
|
||||
buildFailureMessage: function() {
|
||||
return 'default message';
|
||||
}
|
||||
@@ -287,7 +290,7 @@ describe('Expectation', function() {
|
||||
expectation = jasmineUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
actual: 'an actual',
|
||||
util: util,
|
||||
matchersUtil: matchersUtil,
|
||||
addExpectationResult: addExpectationResult
|
||||
}).not;
|
||||
|
||||
@@ -539,7 +542,7 @@ describe('Expectation', function() {
|
||||
};
|
||||
}
|
||||
},
|
||||
util = {
|
||||
matchersUtil = {
|
||||
buildFailureMessage: function() {
|
||||
return 'failure message';
|
||||
}
|
||||
@@ -547,7 +550,7 @@ describe('Expectation', function() {
|
||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||
expectation = jasmineUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
util: util,
|
||||
matchersUtil: matchersUtil,
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
});
|
||||
@@ -635,7 +638,7 @@ describe('Expectation', function() {
|
||||
pp = jasmineUnderTest.makePrettyPrinter(),
|
||||
expectation = jasmineUnderTest.Expectation.factory({
|
||||
customMatchers: matchers,
|
||||
util: new jasmineUnderTest.MatchersUtil({ pp: pp }),
|
||||
matchersUtil: new jasmineUnderTest.MatchersUtil({ pp: pp }),
|
||||
actual: 'an actual',
|
||||
addExpectationResult: addExpectationResult
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe("toBe", function() {
|
||||
it("passes with no message when actual === expected", function() {
|
||||
var util = new jasmineUnderTest.MatchersUtil(),
|
||||
matcher = jasmineUnderTest.matchers.toBe(util),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
|
||||
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
|
||||
result;
|
||||
|
||||
result = matcher.compare(1, 1);
|
||||
@@ -9,8 +9,8 @@ describe("toBe", function() {
|
||||
});
|
||||
|
||||
it("passes with a custom message when expected is an array", function() {
|
||||
var util = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.matchers.toBe(util),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
|
||||
result,
|
||||
array = [1];
|
||||
|
||||
@@ -20,8 +20,8 @@ describe("toBe", function() {
|
||||
});
|
||||
|
||||
it("passes with a custom message when expected is an object", function() {
|
||||
var util = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.matchers.toBe(util),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
|
||||
result,
|
||||
obj = {foo: "bar"};
|
||||
|
||||
@@ -31,8 +31,8 @@ describe("toBe", function() {
|
||||
});
|
||||
|
||||
it("fails with no message when actual !== expected", function() {
|
||||
var util = new jasmineUnderTest.MatchersUtil(),
|
||||
matcher = jasmineUnderTest.matchers.toBe(util),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
|
||||
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
|
||||
result;
|
||||
|
||||
result = matcher.compare(1, 2);
|
||||
@@ -41,8 +41,8 @@ describe("toBe", function() {
|
||||
});
|
||||
|
||||
it("fails with a custom message when expected is an array", function() {
|
||||
var util = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.matchers.toBe(util),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
|
||||
result;
|
||||
|
||||
result = matcher.compare([1], [1]);
|
||||
@@ -51,8 +51,8 @@ describe("toBe", function() {
|
||||
});
|
||||
|
||||
it("fails with a custom message when expected is an object", function() {
|
||||
var util = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.matchers.toBe(util),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
|
||||
result;
|
||||
|
||||
result = matcher.compare({foo: "bar"}, {foo: "bar"});
|
||||
@@ -63,8 +63,8 @@ describe("toBe", function() {
|
||||
it("works with custom object formatters when expected is an object", function() {
|
||||
var formatter = function(x) { return '<' + x.foo + '>'; },
|
||||
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]),
|
||||
util = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
|
||||
matcher = jasmineUnderTest.matchers.toBe(util),
|
||||
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
|
||||
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
|
||||
result;
|
||||
|
||||
result = matcher.compare({foo: "bar"}, {foo: "bar"});
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
describe("toContain", function() {
|
||||
it("delegates to jasmineUnderTest.matchersUtil.contains", function() {
|
||||
var util = {
|
||||
var matchersUtil = {
|
||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toContain(util),
|
||||
matcher = jasmineUnderTest.matchers.toContain(matchersUtil),
|
||||
result;
|
||||
|
||||
result = matcher.compare("ABC", "B");
|
||||
expect(util.contains).toHaveBeenCalledWith("ABC", "B");
|
||||
expect(matchersUtil.contains).toHaveBeenCalledWith("ABC", "B");
|
||||
expect(result.pass).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ describe("toEqual", function() {
|
||||
"use strict";
|
||||
|
||||
function compareEquals(actual, expected) {
|
||||
var util = new jasmineUnderTest.MatchersUtil({
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = jasmineUnderTest.matchers.toEqual(util);
|
||||
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil);
|
||||
|
||||
var result = matcher.compare(actual, expected);
|
||||
|
||||
@@ -13,19 +13,19 @@ describe("toEqual", function() {
|
||||
}
|
||||
|
||||
it("delegates to equals function", function() {
|
||||
var util = {
|
||||
var matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
|
||||
buildFailureMessage: function() {
|
||||
return 'does not matter'
|
||||
return 'does not matter';
|
||||
},
|
||||
DiffBuilder: new jasmineUnderTest.DiffBuilder()
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toEqual(util),
|
||||
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
|
||||
result;
|
||||
|
||||
result = matcher.compare(1, 1);
|
||||
|
||||
expect(util.equals).toHaveBeenCalledWith(1, 1, jasmine.anything());
|
||||
expect(matchersUtil.equals).toHaveBeenCalledWith(1, 1, jasmine.anything());
|
||||
expect(result.pass).toBe(true);
|
||||
});
|
||||
|
||||
@@ -33,8 +33,8 @@ describe("toEqual", function() {
|
||||
var tester = function (a, b) {
|
||||
return a.toString() === b.toString();
|
||||
},
|
||||
util = new jasmineUnderTest.MatchersUtil({customTesters: [tester]}),
|
||||
matcher = jasmineUnderTest.matchers.toEqual(util),
|
||||
matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: [tester]}),
|
||||
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
|
||||
result;
|
||||
|
||||
result = matcher.compare(1, '1');
|
||||
@@ -107,8 +107,8 @@ describe("toEqual", function() {
|
||||
var actual = {x: {y: 1, z: 2, f: 4}},
|
||||
expected = {x: {y: 1, z: 2, g: 3}},
|
||||
pp = jasmineUnderTest.makePrettyPrinter([formatter]),
|
||||
util = new jasmineUnderTest.MatchersUtil({pp: pp}),
|
||||
matcher = jasmineUnderTest.matchers.toEqual(util),
|
||||
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp}),
|
||||
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
|
||||
message =
|
||||
"Expected $.x to have properties\n" +
|
||||
" g: |3|\n" +
|
||||
@@ -128,8 +128,8 @@ describe("toEqual", function() {
|
||||
var actual = [{foo: 4}],
|
||||
expected = [{foo: 5}],
|
||||
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]),
|
||||
util = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
|
||||
matcher = jasmineUnderTest.matchers.toEqual(util),
|
||||
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
|
||||
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
|
||||
message = "Expected $[0].foo = |4| to equal |5|.";
|
||||
|
||||
expect(matcher.compare(actual, expected).message).toEqual(message);
|
||||
@@ -151,8 +151,8 @@ describe("toEqual", function() {
|
||||
bar: "shouldn't be pretty printed"
|
||||
}],
|
||||
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]),
|
||||
util = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
|
||||
matcher = jasmineUnderTest.matchers.toEqual(util),
|
||||
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
|
||||
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
|
||||
message = "Expected $[0].foo = [thing with a=1, b=2] to equal [thing with a=5, b=2].\n" +
|
||||
"Expected $[0].bar = 'should not be pretty printed' to equal 'shouldn't be pretty printed'.";
|
||||
|
||||
@@ -348,8 +348,8 @@ describe("toEqual", function() {
|
||||
expected = {x: new Bar()},
|
||||
message = "Expected $.x to be a kind of Bar, but was |[object Object]|.",
|
||||
pp = jasmineUnderTest.makePrettyPrinter([formatter]),
|
||||
util = new jasmineUnderTest.MatchersUtil({pp: pp}),
|
||||
matcher = jasmineUnderTest.matchers.toEqual(util);
|
||||
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp}),
|
||||
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil);
|
||||
|
||||
expect(matcher.compare(actual, expected).message).toEqual(message);
|
||||
});
|
||||
@@ -889,8 +889,8 @@ describe("toEqual", function() {
|
||||
var actual = [1, 1, 2, 3, 5],
|
||||
expected = [1, 1, 2, 3],
|
||||
pp = jasmineUnderTest.makePrettyPrinter([formatter]),
|
||||
util = new jasmineUnderTest.MatchersUtil({pp: pp}),
|
||||
matcher = jasmineUnderTest.matchers.toEqual(util),
|
||||
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp}),
|
||||
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
|
||||
message = 'Expected $.length = |5| to equal |4|.\n' +
|
||||
'Unexpected $[4] = |5| in array.';
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
describe("toHaveBeenCalledWith", function() {
|
||||
|
||||
it("passes when the actual was called with matching parameters", function() {
|
||||
var util = {
|
||||
var matchersUtil = {
|
||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
|
||||
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
|
||||
calledSpy = new jasmineUnderTest.Env().createSpy('called-spy'),
|
||||
result;
|
||||
|
||||
@@ -29,11 +29,11 @@ describe("toHaveBeenCalledWith", function() {
|
||||
});
|
||||
|
||||
it("fails when the actual was not called", function() {
|
||||
var util = {
|
||||
var matchersUtil = {
|
||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(false),
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
|
||||
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
|
||||
uncalledSpy = new jasmineUnderTest.Env().createSpy('uncalled spy'),
|
||||
result;
|
||||
|
||||
@@ -43,8 +43,8 @@ describe("toHaveBeenCalledWith", function() {
|
||||
});
|
||||
|
||||
it("fails when the actual was called with different parameters", function() {
|
||||
var util = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
|
||||
calledSpy = new jasmineUnderTest.Env().createSpy('called spy'),
|
||||
result;
|
||||
|
||||
|
||||
@@ -192,10 +192,7 @@ describe("toThrowError", function() {
|
||||
});
|
||||
|
||||
it("passes if thrown is an Error and the expected the same Error", function() {
|
||||
var util = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||
fn = function() {
|
||||
throw new Error();
|
||||
},
|
||||
@@ -208,10 +205,7 @@ describe("toThrowError", function() {
|
||||
});
|
||||
|
||||
it("passes if thrown is a custom error that takes arguments and the expected is the same error", function() {
|
||||
var util = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||
CustomError = function CustomError(arg) { arg.x },
|
||||
fn = function() {
|
||||
throw new CustomError({ x: 1 });
|
||||
@@ -227,10 +221,7 @@ describe("toThrowError", function() {
|
||||
});
|
||||
|
||||
it("fails if thrown is an Error and the expected is a different Error", function() {
|
||||
var util = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||
fn = function() {
|
||||
throw new Error();
|
||||
},
|
||||
@@ -243,11 +234,11 @@ describe("toThrowError", function() {
|
||||
});
|
||||
|
||||
it("passes if thrown is a type of Error and it is equal to the expected Error and message", function() {
|
||||
var util = {
|
||||
var matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(util),
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
|
||||
fn = function() {
|
||||
throw new TypeError("foo");
|
||||
},
|
||||
@@ -260,12 +251,12 @@ describe("toThrowError", function() {
|
||||
});
|
||||
|
||||
it("passes if thrown is a custom error that takes arguments and it is equal to the expected custom error and message", function() {
|
||||
var util = {
|
||||
var matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(util),
|
||||
CustomError = function CustomError(arg) { this.message = arg.message },
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
|
||||
CustomError = function CustomError(arg) { this.message = arg.message; },
|
||||
fn = function() {
|
||||
throw new CustomError({message: "foo"});
|
||||
},
|
||||
@@ -280,11 +271,11 @@ describe("toThrowError", function() {
|
||||
});
|
||||
|
||||
it("fails if thrown is a type of Error and the expected is a different Error", function() {
|
||||
var util = {
|
||||
var matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(util),
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
|
||||
fn = function() {
|
||||
throw new TypeError("foo");
|
||||
},
|
||||
@@ -297,11 +288,11 @@ describe("toThrowError", function() {
|
||||
});
|
||||
|
||||
it("passes if thrown is a type of Error and has the same type as the expected Error and the message matches the expected message", function() {
|
||||
var util = {
|
||||
var matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(util),
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
|
||||
fn = function() {
|
||||
throw new TypeError("foo");
|
||||
},
|
||||
@@ -314,11 +305,11 @@ describe("toThrowError", function() {
|
||||
});
|
||||
|
||||
it("fails if thrown is a type of Error and the expected is a different Error", function() {
|
||||
var util = {
|
||||
var matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(util),
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
|
||||
fn = function() {
|
||||
throw new TypeError("foo");
|
||||
},
|
||||
|
||||
@@ -23,11 +23,11 @@ describe("toThrow", function() {
|
||||
});
|
||||
|
||||
it("passes if it throws but there is no expected", function() {
|
||||
var util = {
|
||||
var matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toThrow(util),
|
||||
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
|
||||
fn = function() {
|
||||
throw 5;
|
||||
},
|
||||
@@ -54,11 +54,11 @@ describe("toThrow", function() {
|
||||
});
|
||||
|
||||
it("passes if what is thrown is equivalent to what is expected", function() {
|
||||
var util = {
|
||||
var matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toThrow(util),
|
||||
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
|
||||
fn = function() {
|
||||
throw 5;
|
||||
},
|
||||
@@ -71,11 +71,11 @@ describe("toThrow", function() {
|
||||
});
|
||||
|
||||
it("fails if what is thrown is not equivalent to what is expected", function() {
|
||||
var util = {
|
||||
var matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toThrow(util),
|
||||
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
|
||||
fn = function() {
|
||||
throw 5;
|
||||
},
|
||||
@@ -88,11 +88,11 @@ describe("toThrow", function() {
|
||||
});
|
||||
|
||||
it("fails if what is thrown is not equivalent to undefined", function() {
|
||||
var util = {
|
||||
var matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toThrow(util),
|
||||
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
|
||||
fn = function() {
|
||||
throw 5;
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
(function(env) {
|
||||
env.registerIntegrationMatchers = function() {
|
||||
jasmine.addMatchers({
|
||||
toHaveFailedExpectationsForRunnable: function(util) {
|
||||
toHaveFailedExpectationsForRunnable: function() {
|
||||
return {
|
||||
compare: function(actual, fullName, expectedFailures) {
|
||||
var foundRunnable = false,
|
||||
|
||||
@@ -23,7 +23,7 @@ describe('npm package', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
jasmine.addMatchers({
|
||||
toExistInPath: function(util) {
|
||||
toExistInPath: function() {
|
||||
return {
|
||||
compare: function(actual, expected) {
|
||||
var fullPath = path.resolve(expected, actual);
|
||||
|
||||
@@ -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