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;
|
runnableResources[spec.id].customEqualityTesters;
|
||||||
|
|
||||||
return j$.Expectation.factory({
|
return j$.Expectation.factory({
|
||||||
util: makeMatchersUtil(),
|
matchersUtil: makeMatchersUtil(),
|
||||||
customEqualityTesters: customEqualityTesters,
|
customEqualityTesters: customEqualityTesters,
|
||||||
customMatchers: runnableResources[spec.id].customMatchers,
|
customMatchers: runnableResources[spec.id].customMatchers,
|
||||||
actual: actual,
|
actual: actual,
|
||||||
@@ -1277,7 +1277,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
|
|
||||||
var asyncExpectationFactory = function(actual, spec) {
|
var asyncExpectationFactory = function(actual, spec) {
|
||||||
return j$.Expectation.asyncFactory({
|
return j$.Expectation.asyncFactory({
|
||||||
util: makeMatchersUtil(),
|
matchersUtil: makeMatchersUtil(),
|
||||||
customEqualityTesters: runnableResources[spec.id].customEqualityTesters,
|
customEqualityTesters: runnableResources[spec.id].customEqualityTesters,
|
||||||
customAsyncMatchers: runnableResources[spec.id].customAsyncMatchers,
|
customAsyncMatchers: runnableResources[spec.id].customAsyncMatchers,
|
||||||
actual: actual,
|
actual: actual,
|
||||||
@@ -3561,7 +3561,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function negatedFailureMessage(result, matcherName, args, util) {
|
function negatedFailureMessage(result, matcherName, args, matchersUtil) {
|
||||||
if (result.message) {
|
if (result.message) {
|
||||||
if (j$.isFunction_(result.message)) {
|
if (j$.isFunction_(result.message)) {
|
||||||
return result.message();
|
return result.message();
|
||||||
@@ -3573,7 +3573,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
|||||||
args = args.slice();
|
args = args.slice();
|
||||||
args.unshift(true);
|
args.unshift(true);
|
||||||
args.unshift(matcherName);
|
args.unshift(matcherName);
|
||||||
return util.buildFailureMessage.apply(util, args);
|
return matchersUtil.buildFailureMessage.apply(matchersUtil, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
function negate(result) {
|
function negate(result) {
|
||||||
@@ -3645,7 +3645,7 @@ getJasmineRequireObj().ExpectationFilterChain = function() {
|
|||||||
result,
|
result,
|
||||||
matcherName,
|
matcherName,
|
||||||
args,
|
args,
|
||||||
util
|
matchersUtil
|
||||||
) {
|
) {
|
||||||
return this.callFirst_('buildFailureMessage', arguments).result;
|
return this.callFirst_('buildFailureMessage', arguments).result;
|
||||||
};
|
};
|
||||||
@@ -3747,7 +3747,9 @@ getJasmineRequireObj().buildExpectationResult = function() {
|
|||||||
|
|
||||||
getJasmineRequireObj().Expector = function(j$) {
|
getJasmineRequireObj().Expector = function(j$) {
|
||||||
function Expector(options) {
|
function Expector(options) {
|
||||||
this.util = options.util || { buildFailureMessage: function() {} };
|
this.matchersUtil = options.matchersUtil || {
|
||||||
|
buildFailureMessage: function() {}
|
||||||
|
};
|
||||||
this.customEqualityTesters = options.customEqualityTesters || [];
|
this.customEqualityTesters = options.customEqualityTesters || [];
|
||||||
this.actual = options.actual;
|
this.actual = options.actual;
|
||||||
this.addExpectationResult = options.addExpectationResult || function() {};
|
this.addExpectationResult = options.addExpectationResult || function() {};
|
||||||
@@ -3765,7 +3767,7 @@ getJasmineRequireObj().Expector = function(j$) {
|
|||||||
|
|
||||||
this.args.unshift(this.actual);
|
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);
|
var comparisonFunc = this.filters.selectComparisonFunc(matcher);
|
||||||
return comparisonFunc || matcher.compare;
|
return comparisonFunc || matcher.compare;
|
||||||
};
|
};
|
||||||
@@ -3781,7 +3783,7 @@ getJasmineRequireObj().Expector = function(j$) {
|
|||||||
result,
|
result,
|
||||||
this.matcherName,
|
this.matcherName,
|
||||||
this.args,
|
this.args,
|
||||||
this.util,
|
this.matchersUtil,
|
||||||
defaultMessage
|
defaultMessage
|
||||||
);
|
);
|
||||||
return this.filters.modifyFailureMessage(msg || defaultMessage());
|
return this.filters.modifyFailureMessage(msg || defaultMessage());
|
||||||
@@ -3791,7 +3793,10 @@ getJasmineRequireObj().Expector = function(j$) {
|
|||||||
var args = self.args.slice();
|
var args = self.args.slice();
|
||||||
args.unshift(false);
|
args.unshift(false);
|
||||||
args.unshift(self.matcherName);
|
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)) {
|
} else if (j$.isFunction_(result.message)) {
|
||||||
return result.message();
|
return result.message();
|
||||||
} else {
|
} else {
|
||||||
@@ -3943,7 +3948,7 @@ getJasmineRequireObj().toBeRejected = function(j$) {
|
|||||||
* @example
|
* @example
|
||||||
* return expectAsync(aPromise).toBeRejected();
|
* return expectAsync(aPromise).toBeRejected();
|
||||||
*/
|
*/
|
||||||
return function toBeRejected(util) {
|
return function toBeRejected() {
|
||||||
return {
|
return {
|
||||||
compare: function(actual) {
|
compare: function(actual) {
|
||||||
if (!j$.isPromiseLike(actual)) {
|
if (!j$.isPromiseLike(actual)) {
|
||||||
@@ -4120,7 +4125,7 @@ getJasmineRequireObj().toBeResolved = function(j$) {
|
|||||||
* @example
|
* @example
|
||||||
* return expectAsync(aPromise).toBeResolved();
|
* return expectAsync(aPromise).toBeResolved();
|
||||||
*/
|
*/
|
||||||
return function toBeResolved(util) {
|
return function toBeResolved() {
|
||||||
return {
|
return {
|
||||||
compare: function(actual) {
|
compare: function(actual) {
|
||||||
if (!j$.isPromiseLike(actual)) {
|
if (!j$.isPromiseLike(actual)) {
|
||||||
@@ -4972,7 +4977,7 @@ getJasmineRequireObj().toBe = function(j$) {
|
|||||||
* @example
|
* @example
|
||||||
* expect(thing).toBe(realThing);
|
* expect(thing).toBe(realThing);
|
||||||
*/
|
*/
|
||||||
function toBe(util) {
|
function toBe(matchersUtil) {
|
||||||
var tip = ' Tip: To check for deep equality, use .toEqual() instead of .toBe().';
|
var tip = ' Tip: To check for deep equality, use .toEqual() instead of .toBe().';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -4982,7 +4987,7 @@ getJasmineRequireObj().toBe = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (typeof expected === 'object') {
|
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;
|
return result;
|
||||||
@@ -5428,12 +5433,12 @@ getJasmineRequireObj().toContain = function() {
|
|||||||
* expect(array).toContain(anElement);
|
* expect(array).toContain(anElement);
|
||||||
* expect(string).toContain(substring);
|
* expect(string).toContain(substring);
|
||||||
*/
|
*/
|
||||||
function toContain(util) {
|
function toContain(matchersUtil) {
|
||||||
return {
|
return {
|
||||||
compare: function(actual, expected) {
|
compare: function(actual, expected) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pass: util.contains(actual, expected)
|
pass: matchersUtil.contains(actual, expected)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -5452,15 +5457,15 @@ getJasmineRequireObj().toEqual = function(j$) {
|
|||||||
* @example
|
* @example
|
||||||
* expect(bigObject).toEqual({"foo": ['bar', 'baz']});
|
* expect(bigObject).toEqual({"foo": ['bar', 'baz']});
|
||||||
*/
|
*/
|
||||||
function toEqual(util) {
|
function toEqual(matchersUtil) {
|
||||||
return {
|
return {
|
||||||
compare: function(actual, expected) {
|
compare: function(actual, expected) {
|
||||||
var result = {
|
var result = {
|
||||||
pass: false
|
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
|
// TODO: only set error message if test fails
|
||||||
result.message = diffBuilder.getMessage();
|
result.message = diffBuilder.getMessage();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ describe('AsyncExpectation', function() {
|
|||||||
actual = Promise.resolve(),
|
actual = Promise.resolve(),
|
||||||
pp = jasmineUnderTest.makePrettyPrinter(),
|
pp = jasmineUnderTest.makePrettyPrinter(),
|
||||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
util: new jasmineUnderTest.MatchersUtil({ pp: pp }),
|
matchersUtil: new jasmineUnderTest.MatchersUtil({ pp: pp }),
|
||||||
actual: actual,
|
actual: actual,
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
@@ -48,7 +48,9 @@ describe('AsyncExpectation', function() {
|
|||||||
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
var addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
actual = Promise.reject(),
|
actual = Promise.reject(),
|
||||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
util: new jasmineUnderTest.MatchersUtil({ pp: function() {} }),
|
matchersUtil: new jasmineUnderTest.MatchersUtil({
|
||||||
|
pp: function() {}
|
||||||
|
}),
|
||||||
actual: actual,
|
actual: actual,
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
@@ -92,7 +94,7 @@ describe('AsyncExpectation', function() {
|
|||||||
it('prepends the context to the generated failure message', function() {
|
it('prepends the context to the generated failure message', function() {
|
||||||
jasmine.getEnv().requirePromises();
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
var util = {
|
var matchersUtil = {
|
||||||
buildFailureMessage: function() {
|
buildFailureMessage: function() {
|
||||||
return 'failure message';
|
return 'failure message';
|
||||||
}
|
}
|
||||||
@@ -101,7 +103,7 @@ describe('AsyncExpectation', function() {
|
|||||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
actual: Promise.reject('rejected'),
|
actual: Promise.reject('rejected'),
|
||||||
addExpectationResult: addExpectationResult,
|
addExpectationResult: addExpectationResult,
|
||||||
util: util
|
matchersUtil: matchersUtil
|
||||||
});
|
});
|
||||||
|
|
||||||
return expectation
|
return expectation
|
||||||
@@ -120,7 +122,7 @@ describe('AsyncExpectation', function() {
|
|||||||
it('prepends the context to a custom failure message', function() {
|
it('prepends the context to a custom failure message', function() {
|
||||||
jasmine.getEnv().requirePromises();
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
var util = {
|
var matchersUtil = {
|
||||||
buildFailureMessage: function() {
|
buildFailureMessage: function() {
|
||||||
return 'failure message';
|
return 'failure message';
|
||||||
},
|
},
|
||||||
@@ -130,7 +132,7 @@ describe('AsyncExpectation', function() {
|
|||||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
actual: Promise.reject('b'),
|
actual: Promise.reject('b'),
|
||||||
addExpectationResult: addExpectationResult,
|
addExpectationResult: addExpectationResult,
|
||||||
util: util
|
matchersUtil: matchersUtil
|
||||||
});
|
});
|
||||||
|
|
||||||
return expectation
|
return expectation
|
||||||
@@ -151,7 +153,7 @@ describe('AsyncExpectation', function() {
|
|||||||
pending('should actually work, but no custom matchers for async yet');
|
pending('should actually work, but no custom matchers for async yet');
|
||||||
jasmine.getEnv().requirePromises();
|
jasmine.getEnv().requirePromises();
|
||||||
|
|
||||||
var util = {
|
var matchersUtil = {
|
||||||
buildFailureMessage: function() {
|
buildFailureMessage: function() {
|
||||||
return 'failure message';
|
return 'failure message';
|
||||||
}
|
}
|
||||||
@@ -161,7 +163,7 @@ describe('AsyncExpectation', function() {
|
|||||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
actual: actual,
|
actual: actual,
|
||||||
addExpectationResult: addExpectationResult,
|
addExpectationResult: addExpectationResult,
|
||||||
util: util
|
matchersUtil: matchersUtil
|
||||||
});
|
});
|
||||||
|
|
||||||
return expectation
|
return expectation
|
||||||
@@ -186,7 +188,7 @@ describe('AsyncExpectation', function() {
|
|||||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
actual: actual,
|
actual: actual,
|
||||||
addExpectationResult: addExpectationResult,
|
addExpectationResult: addExpectationResult,
|
||||||
util: new jasmineUnderTest.MatchersUtil({ pp: pp })
|
matchersUtil: new jasmineUnderTest.MatchersUtil({ pp: pp })
|
||||||
});
|
});
|
||||||
|
|
||||||
return expectation
|
return expectation
|
||||||
@@ -211,7 +213,7 @@ describe('AsyncExpectation', function() {
|
|||||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
actual: actual,
|
actual: actual,
|
||||||
addExpectationResult: addExpectationResult,
|
addExpectationResult: addExpectationResult,
|
||||||
util: new jasmineUnderTest.MatchersUtil({
|
matchersUtil: new jasmineUnderTest.MatchersUtil({
|
||||||
pp: jasmineUnderTest.makePrettyPrinter()
|
pp: jasmineUnderTest.makePrettyPrinter()
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@@ -261,7 +263,7 @@ describe('AsyncExpectation', function() {
|
|||||||
matchers = {
|
matchers = {
|
||||||
toFoo: matcherFactory
|
toFoo: matcherFactory
|
||||||
},
|
},
|
||||||
util = {
|
matchersUtil = {
|
||||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||||
},
|
},
|
||||||
customEqualityTesters = ['a'],
|
customEqualityTesters = ['a'],
|
||||||
@@ -269,7 +271,7 @@ describe('AsyncExpectation', function() {
|
|||||||
expectation;
|
expectation;
|
||||||
|
|
||||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
util: util,
|
matchersUtil: matchersUtil,
|
||||||
customAsyncMatchers: matchers,
|
customAsyncMatchers: matchers,
|
||||||
customEqualityTesters: customEqualityTesters,
|
customEqualityTesters: customEqualityTesters,
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
@@ -278,7 +280,7 @@ describe('AsyncExpectation', function() {
|
|||||||
|
|
||||||
return expectation.toFoo('hello').then(function() {
|
return expectation.toFoo('hello').then(function() {
|
||||||
expect(matcherFactory).toHaveBeenCalledWith(
|
expect(matcherFactory).toHaveBeenCalledWith(
|
||||||
util,
|
matchersUtil,
|
||||||
customEqualityTesters
|
customEqualityTesters
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -297,14 +299,14 @@ describe('AsyncExpectation', function() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
util = {
|
matchersUtil = {
|
||||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||||
},
|
},
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
expectation;
|
expectation;
|
||||||
|
|
||||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
util: util,
|
matchersUtil: matchersUtil,
|
||||||
customAsyncMatchers: matchers,
|
customAsyncMatchers: matchers,
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
@@ -327,7 +329,7 @@ describe('AsyncExpectation', function() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
util = {
|
matchersUtil = {
|
||||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||||
},
|
},
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
@@ -340,7 +342,7 @@ describe('AsyncExpectation', function() {
|
|||||||
|
|
||||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
customAsyncMatchers: matchers,
|
customAsyncMatchers: matchers,
|
||||||
util: util,
|
matchersUtil: matchersUtil,
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
@@ -370,7 +372,7 @@ describe('AsyncExpectation', function() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
util = {
|
matchersUtil = {
|
||||||
buildFailureMessage: function() {
|
buildFailureMessage: function() {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -385,7 +387,7 @@ describe('AsyncExpectation', function() {
|
|||||||
|
|
||||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
customAsyncMatchers: matchers,
|
customAsyncMatchers: matchers,
|
||||||
util: util,
|
matchersUtil: matchersUtil,
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
@@ -541,7 +543,7 @@ describe('AsyncExpectation', function() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
util = {
|
matchersUtil = {
|
||||||
buildFailureMessage: function() {
|
buildFailureMessage: function() {
|
||||||
return 'default message';
|
return 'default message';
|
||||||
}
|
}
|
||||||
@@ -558,7 +560,7 @@ describe('AsyncExpectation', function() {
|
|||||||
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
customAsyncMatchers: matchers,
|
customAsyncMatchers: matchers,
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
util: util,
|
matchersUtil: matchersUtil,
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
}).not;
|
}).not;
|
||||||
|
|
||||||
|
|||||||
@@ -72,21 +72,21 @@ describe('ExpectationFilterChain', function() {
|
|||||||
matcherResult = { pass: false },
|
matcherResult = { pass: false },
|
||||||
matcherName = 'foo',
|
matcherName = 'foo',
|
||||||
args = [],
|
args = [],
|
||||||
util = {},
|
matchersUtil = {},
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = chain.buildFailureMessage(
|
result = chain.buildFailureMessage(
|
||||||
matcherResult,
|
matcherResult,
|
||||||
matcherName,
|
matcherName,
|
||||||
args,
|
args,
|
||||||
util
|
matchersUtil
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(first).toHaveBeenCalledWith(
|
expect(first).toHaveBeenCalledWith(
|
||||||
matcherResult,
|
matcherResult,
|
||||||
matcherName,
|
matcherName,
|
||||||
args,
|
args,
|
||||||
util
|
matchersUtil
|
||||||
);
|
);
|
||||||
expect(second).not.toHaveBeenCalled();
|
expect(second).not.toHaveBeenCalled();
|
||||||
expect(result).toEqual('first');
|
expect(result).toEqual('first');
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ describe('Expectation', function() {
|
|||||||
matchers = {
|
matchers = {
|
||||||
toFoo: matcherFactory
|
toFoo: matcherFactory
|
||||||
},
|
},
|
||||||
util = {
|
matchersUtil = {
|
||||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||||
},
|
},
|
||||||
customEqualityTesters = ['a'],
|
customEqualityTesters = ['a'],
|
||||||
@@ -45,7 +45,7 @@ describe('Expectation', function() {
|
|||||||
expectation;
|
expectation;
|
||||||
|
|
||||||
expectation = jasmineUnderTest.Expectation.factory({
|
expectation = jasmineUnderTest.Expectation.factory({
|
||||||
util: util,
|
matchersUtil: matchersUtil,
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
customEqualityTesters: customEqualityTesters,
|
customEqualityTesters: customEqualityTesters,
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
@@ -54,7 +54,10 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
expectation.toFoo('hello');
|
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() {
|
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')
|
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||||
},
|
},
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
expectation;
|
expectation;
|
||||||
|
|
||||||
expectation = jasmineUnderTest.Expectation.factory({
|
expectation = jasmineUnderTest.Expectation.factory({
|
||||||
util: util,
|
matchersUtil: matchersUtil,
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
@@ -96,7 +99,7 @@ describe('Expectation', function() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
util = {
|
matchersUtil = {
|
||||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||||
},
|
},
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
@@ -104,7 +107,7 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
expectation = jasmineUnderTest.Expectation.factory({
|
expectation = jasmineUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
util: util,
|
matchersUtil: matchersUtil,
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
@@ -132,7 +135,7 @@ describe('Expectation', function() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
util = {
|
matchersUtil = {
|
||||||
buildFailureMessage: function() {
|
buildFailureMessage: function() {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -142,7 +145,7 @@ describe('Expectation', function() {
|
|||||||
|
|
||||||
expectation = jasmineUnderTest.Expectation.factory({
|
expectation = jasmineUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
util: util,
|
matchersUtil: matchersUtil,
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
@@ -275,7 +278,7 @@ describe('Expectation', function() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
util = {
|
matchersUtil = {
|
||||||
buildFailureMessage: function() {
|
buildFailureMessage: function() {
|
||||||
return 'default message';
|
return 'default message';
|
||||||
}
|
}
|
||||||
@@ -287,7 +290,7 @@ describe('Expectation', function() {
|
|||||||
expectation = jasmineUnderTest.Expectation.factory({
|
expectation = jasmineUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
util: util,
|
matchersUtil: matchersUtil,
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
}).not;
|
}).not;
|
||||||
|
|
||||||
@@ -539,7 +542,7 @@ describe('Expectation', function() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
util = {
|
matchersUtil = {
|
||||||
buildFailureMessage: function() {
|
buildFailureMessage: function() {
|
||||||
return 'failure message';
|
return 'failure message';
|
||||||
}
|
}
|
||||||
@@ -547,7 +550,7 @@ describe('Expectation', function() {
|
|||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
||||||
expectation = jasmineUnderTest.Expectation.factory({
|
expectation = jasmineUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
util: util,
|
matchersUtil: matchersUtil,
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
@@ -635,7 +638,7 @@ describe('Expectation', function() {
|
|||||||
pp = jasmineUnderTest.makePrettyPrinter(),
|
pp = jasmineUnderTest.makePrettyPrinter(),
|
||||||
expectation = jasmineUnderTest.Expectation.factory({
|
expectation = jasmineUnderTest.Expectation.factory({
|
||||||
customMatchers: matchers,
|
customMatchers: matchers,
|
||||||
util: new jasmineUnderTest.MatchersUtil({ pp: pp }),
|
matchersUtil: new jasmineUnderTest.MatchersUtil({ pp: pp }),
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
addExpectationResult: addExpectationResult
|
addExpectationResult: addExpectationResult
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
describe("toBe", function() {
|
describe("toBe", function() {
|
||||||
it("passes with no message when actual === expected", function() {
|
it("passes with no message when actual === expected", function() {
|
||||||
var util = new jasmineUnderTest.MatchersUtil(),
|
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
|
||||||
matcher = jasmineUnderTest.matchers.toBe(util),
|
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(1, 1);
|
result = matcher.compare(1, 1);
|
||||||
@@ -9,8 +9,8 @@ describe("toBe", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("passes with a custom message when expected is an array", function() {
|
it("passes with a custom message when expected is an array", function() {
|
||||||
var util = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||||
matcher = jasmineUnderTest.matchers.toBe(util),
|
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
|
||||||
result,
|
result,
|
||||||
array = [1];
|
array = [1];
|
||||||
|
|
||||||
@@ -20,8 +20,8 @@ describe("toBe", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("passes with a custom message when expected is an object", function() {
|
it("passes with a custom message when expected is an object", function() {
|
||||||
var util = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||||
matcher = jasmineUnderTest.matchers.toBe(util),
|
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
|
||||||
result,
|
result,
|
||||||
obj = {foo: "bar"};
|
obj = {foo: "bar"};
|
||||||
|
|
||||||
@@ -31,8 +31,8 @@ describe("toBe", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails with no message when actual !== expected", function() {
|
it("fails with no message when actual !== expected", function() {
|
||||||
var util = new jasmineUnderTest.MatchersUtil(),
|
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
|
||||||
matcher = jasmineUnderTest.matchers.toBe(util),
|
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(1, 2);
|
result = matcher.compare(1, 2);
|
||||||
@@ -41,8 +41,8 @@ describe("toBe", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails with a custom message when expected is an array", function() {
|
it("fails with a custom message when expected is an array", function() {
|
||||||
var util = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||||
matcher = jasmineUnderTest.matchers.toBe(util),
|
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare([1], [1]);
|
result = matcher.compare([1], [1]);
|
||||||
@@ -51,8 +51,8 @@ describe("toBe", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails with a custom message when expected is an object", function() {
|
it("fails with a custom message when expected is an object", function() {
|
||||||
var util = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||||
matcher = jasmineUnderTest.matchers.toBe(util),
|
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare({foo: "bar"}, {foo: "bar"});
|
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() {
|
it("works with custom object formatters when expected is an object", function() {
|
||||||
var formatter = function(x) { return '<' + x.foo + '>'; },
|
var formatter = function(x) { return '<' + x.foo + '>'; },
|
||||||
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]),
|
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]),
|
||||||
util = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
|
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
|
||||||
matcher = jasmineUnderTest.matchers.toBe(util),
|
matcher = jasmineUnderTest.matchers.toBe(matchersUtil),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare({foo: "bar"}, {foo: "bar"});
|
result = matcher.compare({foo: "bar"}, {foo: "bar"});
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
describe("toContain", function() {
|
describe("toContain", function() {
|
||||||
it("delegates to jasmineUnderTest.matchersUtil.contains", function() {
|
it("delegates to jasmineUnderTest.matchersUtil.contains", function() {
|
||||||
var util = {
|
var matchersUtil = {
|
||||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
|
||||||
},
|
},
|
||||||
matcher = jasmineUnderTest.matchers.toContain(util),
|
matcher = jasmineUnderTest.matchers.toContain(matchersUtil),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare("ABC", "B");
|
result = matcher.compare("ABC", "B");
|
||||||
expect(util.contains).toHaveBeenCalledWith("ABC", "B");
|
expect(matchersUtil.contains).toHaveBeenCalledWith("ABC", "B");
|
||||||
expect(result.pass).toBe(true);
|
expect(result.pass).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ describe("toEqual", function() {
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function compareEquals(actual, expected) {
|
function compareEquals(actual, expected) {
|
||||||
var util = new jasmineUnderTest.MatchersUtil({
|
var matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||||
pp: jasmineUnderTest.makePrettyPrinter()
|
pp: jasmineUnderTest.makePrettyPrinter()
|
||||||
}),
|
}),
|
||||||
matcher = jasmineUnderTest.matchers.toEqual(util);
|
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil);
|
||||||
|
|
||||||
var result = matcher.compare(actual, expected);
|
var result = matcher.compare(actual, expected);
|
||||||
|
|
||||||
@@ -13,19 +13,19 @@ describe("toEqual", function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it("delegates to equals function", function() {
|
it("delegates to equals function", function() {
|
||||||
var util = {
|
var matchersUtil = {
|
||||||
equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
|
equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
|
||||||
buildFailureMessage: function() {
|
buildFailureMessage: function() {
|
||||||
return 'does not matter'
|
return 'does not matter';
|
||||||
},
|
},
|
||||||
DiffBuilder: new jasmineUnderTest.DiffBuilder()
|
DiffBuilder: new jasmineUnderTest.DiffBuilder()
|
||||||
},
|
},
|
||||||
matcher = jasmineUnderTest.matchers.toEqual(util),
|
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(1, 1);
|
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);
|
expect(result.pass).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -33,8 +33,8 @@ describe("toEqual", function() {
|
|||||||
var tester = function (a, b) {
|
var tester = function (a, b) {
|
||||||
return a.toString() === b.toString();
|
return a.toString() === b.toString();
|
||||||
},
|
},
|
||||||
util = new jasmineUnderTest.MatchersUtil({customTesters: [tester]}),
|
matchersUtil = new jasmineUnderTest.MatchersUtil({customTesters: [tester]}),
|
||||||
matcher = jasmineUnderTest.matchers.toEqual(util),
|
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
result = matcher.compare(1, '1');
|
result = matcher.compare(1, '1');
|
||||||
@@ -107,8 +107,8 @@ describe("toEqual", function() {
|
|||||||
var actual = {x: {y: 1, z: 2, f: 4}},
|
var actual = {x: {y: 1, z: 2, f: 4}},
|
||||||
expected = {x: {y: 1, z: 2, g: 3}},
|
expected = {x: {y: 1, z: 2, g: 3}},
|
||||||
pp = jasmineUnderTest.makePrettyPrinter([formatter]),
|
pp = jasmineUnderTest.makePrettyPrinter([formatter]),
|
||||||
util = new jasmineUnderTest.MatchersUtil({pp: pp}),
|
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp}),
|
||||||
matcher = jasmineUnderTest.matchers.toEqual(util),
|
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
|
||||||
message =
|
message =
|
||||||
"Expected $.x to have properties\n" +
|
"Expected $.x to have properties\n" +
|
||||||
" g: |3|\n" +
|
" g: |3|\n" +
|
||||||
@@ -128,8 +128,8 @@ describe("toEqual", function() {
|
|||||||
var actual = [{foo: 4}],
|
var actual = [{foo: 4}],
|
||||||
expected = [{foo: 5}],
|
expected = [{foo: 5}],
|
||||||
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]),
|
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]),
|
||||||
util = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
|
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
|
||||||
matcher = jasmineUnderTest.matchers.toEqual(util),
|
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
|
||||||
message = "Expected $[0].foo = |4| to equal |5|.";
|
message = "Expected $[0].foo = |4| to equal |5|.";
|
||||||
|
|
||||||
expect(matcher.compare(actual, expected).message).toEqual(message);
|
expect(matcher.compare(actual, expected).message).toEqual(message);
|
||||||
@@ -151,8 +151,8 @@ describe("toEqual", function() {
|
|||||||
bar: "shouldn't be pretty printed"
|
bar: "shouldn't be pretty printed"
|
||||||
}],
|
}],
|
||||||
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]),
|
prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]),
|
||||||
util = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
|
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: prettyPrinter}),
|
||||||
matcher = jasmineUnderTest.matchers.toEqual(util),
|
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
|
||||||
message = "Expected $[0].foo = [thing with a=1, b=2] to equal [thing with a=5, b=2].\n" +
|
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'.";
|
"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()},
|
expected = {x: new Bar()},
|
||||||
message = "Expected $.x to be a kind of Bar, but was |[object Object]|.",
|
message = "Expected $.x to be a kind of Bar, but was |[object Object]|.",
|
||||||
pp = jasmineUnderTest.makePrettyPrinter([formatter]),
|
pp = jasmineUnderTest.makePrettyPrinter([formatter]),
|
||||||
util = new jasmineUnderTest.MatchersUtil({pp: pp}),
|
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp}),
|
||||||
matcher = jasmineUnderTest.matchers.toEqual(util);
|
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil);
|
||||||
|
|
||||||
expect(matcher.compare(actual, expected).message).toEqual(message);
|
expect(matcher.compare(actual, expected).message).toEqual(message);
|
||||||
});
|
});
|
||||||
@@ -889,8 +889,8 @@ describe("toEqual", function() {
|
|||||||
var actual = [1, 1, 2, 3, 5],
|
var actual = [1, 1, 2, 3, 5],
|
||||||
expected = [1, 1, 2, 3],
|
expected = [1, 1, 2, 3],
|
||||||
pp = jasmineUnderTest.makePrettyPrinter([formatter]),
|
pp = jasmineUnderTest.makePrettyPrinter([formatter]),
|
||||||
util = new jasmineUnderTest.MatchersUtil({pp: pp}),
|
matchersUtil = new jasmineUnderTest.MatchersUtil({pp: pp}),
|
||||||
matcher = jasmineUnderTest.matchers.toEqual(util),
|
matcher = jasmineUnderTest.matchers.toEqual(matchersUtil),
|
||||||
message = 'Expected $.length = |5| to equal |4|.\n' +
|
message = 'Expected $.length = |5| to equal |4|.\n' +
|
||||||
'Unexpected $[4] = |5| in array.';
|
'Unexpected $[4] = |5| in array.';
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
describe("toHaveBeenCalledWith", function() {
|
describe("toHaveBeenCalledWith", function() {
|
||||||
|
|
||||||
it("passes when the actual was called with matching parameters", function() {
|
it("passes when the actual was called with matching parameters", function() {
|
||||||
var util = {
|
var matchersUtil = {
|
||||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
|
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
|
||||||
pp: jasmineUnderTest.makePrettyPrinter()
|
pp: jasmineUnderTest.makePrettyPrinter()
|
||||||
},
|
},
|
||||||
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
|
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
|
||||||
calledSpy = new jasmineUnderTest.Env().createSpy('called-spy'),
|
calledSpy = new jasmineUnderTest.Env().createSpy('called-spy'),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
@@ -29,11 +29,11 @@ describe("toHaveBeenCalledWith", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails when the actual was not called", function() {
|
it("fails when the actual was not called", function() {
|
||||||
var util = {
|
var matchersUtil = {
|
||||||
contains: jasmine.createSpy('delegated-contains').and.returnValue(false),
|
contains: jasmine.createSpy('delegated-contains').and.returnValue(false),
|
||||||
pp: jasmineUnderTest.makePrettyPrinter()
|
pp: jasmineUnderTest.makePrettyPrinter()
|
||||||
},
|
},
|
||||||
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
|
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
|
||||||
uncalledSpy = new jasmineUnderTest.Env().createSpy('uncalled spy'),
|
uncalledSpy = new jasmineUnderTest.Env().createSpy('uncalled spy'),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
@@ -43,8 +43,8 @@ describe("toHaveBeenCalledWith", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails when the actual was called with different parameters", function() {
|
it("fails when the actual was called with different parameters", function() {
|
||||||
var util = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||||
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(util),
|
matcher = jasmineUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
|
||||||
calledSpy = new jasmineUnderTest.Env().createSpy('called spy'),
|
calledSpy = new jasmineUnderTest.Env().createSpy('called spy'),
|
||||||
result;
|
result;
|
||||||
|
|
||||||
|
|||||||
@@ -192,10 +192,7 @@ describe("toThrowError", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("passes if thrown is an Error and the expected the same Error", function() {
|
it("passes if thrown is an Error and the expected the same Error", function() {
|
||||||
var util = {
|
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
|
||||||
},
|
|
||||||
matcher = jasmineUnderTest.matchers.toThrowError(),
|
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new Error();
|
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() {
|
it("passes if thrown is a custom error that takes arguments and the expected is the same error", function() {
|
||||||
var util = {
|
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true)
|
|
||||||
},
|
|
||||||
matcher = jasmineUnderTest.matchers.toThrowError(),
|
|
||||||
CustomError = function CustomError(arg) { arg.x },
|
CustomError = function CustomError(arg) { arg.x },
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new CustomError({ x: 1 });
|
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() {
|
it("fails if thrown is an Error and the expected is a different Error", function() {
|
||||||
var util = {
|
var matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false)
|
|
||||||
},
|
|
||||||
matcher = jasmineUnderTest.matchers.toThrowError(),
|
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new Error();
|
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() {
|
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),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||||
pp: jasmineUnderTest.makePrettyPrinter()
|
pp: jasmineUnderTest.makePrettyPrinter()
|
||||||
},
|
},
|
||||||
matcher = jasmineUnderTest.matchers.toThrowError(util),
|
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new TypeError("foo");
|
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() {
|
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),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||||
pp: jasmineUnderTest.makePrettyPrinter()
|
pp: jasmineUnderTest.makePrettyPrinter()
|
||||||
},
|
},
|
||||||
matcher = jasmineUnderTest.matchers.toThrowError(util),
|
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
|
||||||
CustomError = function CustomError(arg) { this.message = arg.message },
|
CustomError = function CustomError(arg) { this.message = arg.message; },
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new CustomError({message: "foo"});
|
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() {
|
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),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||||
pp: jasmineUnderTest.makePrettyPrinter()
|
pp: jasmineUnderTest.makePrettyPrinter()
|
||||||
},
|
},
|
||||||
matcher = jasmineUnderTest.matchers.toThrowError(util),
|
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new TypeError("foo");
|
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() {
|
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),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||||
pp: jasmineUnderTest.makePrettyPrinter()
|
pp: jasmineUnderTest.makePrettyPrinter()
|
||||||
},
|
},
|
||||||
matcher = jasmineUnderTest.matchers.toThrowError(util),
|
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new TypeError("foo");
|
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() {
|
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),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||||
pp: jasmineUnderTest.makePrettyPrinter()
|
pp: jasmineUnderTest.makePrettyPrinter()
|
||||||
},
|
},
|
||||||
matcher = jasmineUnderTest.matchers.toThrowError(util),
|
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw new TypeError("foo");
|
throw new TypeError("foo");
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ describe("toThrow", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("passes if it throws but there is no expected", function() {
|
it("passes if it throws but there is no expected", function() {
|
||||||
var util = {
|
var matchersUtil = {
|
||||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||||
pp: jasmineUnderTest.makePrettyPrinter()
|
pp: jasmineUnderTest.makePrettyPrinter()
|
||||||
},
|
},
|
||||||
matcher = jasmineUnderTest.matchers.toThrow(util),
|
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw 5;
|
throw 5;
|
||||||
},
|
},
|
||||||
@@ -54,11 +54,11 @@ describe("toThrow", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("passes if what is thrown is equivalent to what is expected", 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),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||||
pp: jasmineUnderTest.makePrettyPrinter()
|
pp: jasmineUnderTest.makePrettyPrinter()
|
||||||
},
|
},
|
||||||
matcher = jasmineUnderTest.matchers.toThrow(util),
|
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw 5;
|
throw 5;
|
||||||
},
|
},
|
||||||
@@ -71,11 +71,11 @@ describe("toThrow", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails if what is thrown is not equivalent to what is expected", 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),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||||
pp: jasmineUnderTest.makePrettyPrinter()
|
pp: jasmineUnderTest.makePrettyPrinter()
|
||||||
},
|
},
|
||||||
matcher = jasmineUnderTest.matchers.toThrow(util),
|
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw 5;
|
throw 5;
|
||||||
},
|
},
|
||||||
@@ -88,11 +88,11 @@ describe("toThrow", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("fails if what is thrown is not equivalent to undefined", 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),
|
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||||
pp: jasmineUnderTest.makePrettyPrinter()
|
pp: jasmineUnderTest.makePrettyPrinter()
|
||||||
},
|
},
|
||||||
matcher = jasmineUnderTest.matchers.toThrow(util),
|
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
|
||||||
fn = function() {
|
fn = function() {
|
||||||
throw 5;
|
throw 5;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
(function(env) {
|
(function(env) {
|
||||||
env.registerIntegrationMatchers = function() {
|
env.registerIntegrationMatchers = function() {
|
||||||
jasmine.addMatchers({
|
jasmine.addMatchers({
|
||||||
toHaveFailedExpectationsForRunnable: function(util) {
|
toHaveFailedExpectationsForRunnable: function() {
|
||||||
return {
|
return {
|
||||||
compare: function(actual, fullName, expectedFailures) {
|
compare: function(actual, fullName, expectedFailures) {
|
||||||
var foundRunnable = false,
|
var foundRunnable = false,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ describe('npm package', function() {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
jasmine.addMatchers({
|
jasmine.addMatchers({
|
||||||
toExistInPath: function(util) {
|
toExistInPath: function() {
|
||||||
return {
|
return {
|
||||||
compare: function(actual, expected) {
|
compare: function(actual, expected) {
|
||||||
var fullPath = path.resolve(expected, actual);
|
var fullPath = path.resolve(expected, actual);
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
runnableResources[spec.id].customEqualityTesters;
|
runnableResources[spec.id].customEqualityTesters;
|
||||||
|
|
||||||
return j$.Expectation.factory({
|
return j$.Expectation.factory({
|
||||||
util: makeMatchersUtil(),
|
matchersUtil: makeMatchersUtil(),
|
||||||
customEqualityTesters: customEqualityTesters,
|
customEqualityTesters: customEqualityTesters,
|
||||||
customMatchers: runnableResources[spec.id].customMatchers,
|
customMatchers: runnableResources[spec.id].customMatchers,
|
||||||
actual: actual,
|
actual: actual,
|
||||||
@@ -355,7 +355,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
|
|
||||||
var asyncExpectationFactory = function(actual, spec) {
|
var asyncExpectationFactory = function(actual, spec) {
|
||||||
return j$.Expectation.asyncFactory({
|
return j$.Expectation.asyncFactory({
|
||||||
util: makeMatchersUtil(),
|
matchersUtil: makeMatchersUtil(),
|
||||||
customEqualityTesters: runnableResources[spec.id].customEqualityTesters,
|
customEqualityTesters: runnableResources[spec.id].customEqualityTesters,
|
||||||
customAsyncMatchers: runnableResources[spec.id].customAsyncMatchers,
|
customAsyncMatchers: runnableResources[spec.id].customAsyncMatchers,
|
||||||
actual: actual,
|
actual: actual,
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function negatedFailureMessage(result, matcherName, args, util) {
|
function negatedFailureMessage(result, matcherName, args, matchersUtil) {
|
||||||
if (result.message) {
|
if (result.message) {
|
||||||
if (j$.isFunction_(result.message)) {
|
if (j$.isFunction_(result.message)) {
|
||||||
return result.message();
|
return result.message();
|
||||||
@@ -141,7 +141,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
|||||||
args = args.slice();
|
args = args.slice();
|
||||||
args.unshift(true);
|
args.unshift(true);
|
||||||
args.unshift(matcherName);
|
args.unshift(matcherName);
|
||||||
return util.buildFailureMessage.apply(util, args);
|
return matchersUtil.buildFailureMessage.apply(matchersUtil, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
function negate(result) {
|
function negate(result) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ getJasmineRequireObj().ExpectationFilterChain = function() {
|
|||||||
result,
|
result,
|
||||||
matcherName,
|
matcherName,
|
||||||
args,
|
args,
|
||||||
util
|
matchersUtil
|
||||||
) {
|
) {
|
||||||
return this.callFirst_('buildFailureMessage', arguments).result;
|
return this.callFirst_('buildFailureMessage', arguments).result;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
getJasmineRequireObj().Expector = function(j$) {
|
getJasmineRequireObj().Expector = function(j$) {
|
||||||
function Expector(options) {
|
function Expector(options) {
|
||||||
this.util = options.util || { buildFailureMessage: function() {} };
|
this.matchersUtil = options.matchersUtil || {
|
||||||
|
buildFailureMessage: function() {}
|
||||||
|
};
|
||||||
this.customEqualityTesters = options.customEqualityTesters || [];
|
this.customEqualityTesters = options.customEqualityTesters || [];
|
||||||
this.actual = options.actual;
|
this.actual = options.actual;
|
||||||
this.addExpectationResult = options.addExpectationResult || function() {};
|
this.addExpectationResult = options.addExpectationResult || function() {};
|
||||||
@@ -18,7 +20,7 @@ getJasmineRequireObj().Expector = function(j$) {
|
|||||||
|
|
||||||
this.args.unshift(this.actual);
|
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);
|
var comparisonFunc = this.filters.selectComparisonFunc(matcher);
|
||||||
return comparisonFunc || matcher.compare;
|
return comparisonFunc || matcher.compare;
|
||||||
};
|
};
|
||||||
@@ -34,7 +36,7 @@ getJasmineRequireObj().Expector = function(j$) {
|
|||||||
result,
|
result,
|
||||||
this.matcherName,
|
this.matcherName,
|
||||||
this.args,
|
this.args,
|
||||||
this.util,
|
this.matchersUtil,
|
||||||
defaultMessage
|
defaultMessage
|
||||||
);
|
);
|
||||||
return this.filters.modifyFailureMessage(msg || defaultMessage());
|
return this.filters.modifyFailureMessage(msg || defaultMessage());
|
||||||
@@ -44,7 +46,10 @@ getJasmineRequireObj().Expector = function(j$) {
|
|||||||
var args = self.args.slice();
|
var args = self.args.slice();
|
||||||
args.unshift(false);
|
args.unshift(false);
|
||||||
args.unshift(self.matcherName);
|
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)) {
|
} else if (j$.isFunction_(result.message)) {
|
||||||
return result.message();
|
return result.message();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ getJasmineRequireObj().toBeRejected = function(j$) {
|
|||||||
* @example
|
* @example
|
||||||
* return expectAsync(aPromise).toBeRejected();
|
* return expectAsync(aPromise).toBeRejected();
|
||||||
*/
|
*/
|
||||||
return function toBeRejected(util) {
|
return function toBeRejected() {
|
||||||
return {
|
return {
|
||||||
compare: function(actual) {
|
compare: function(actual) {
|
||||||
if (!j$.isPromiseLike(actual)) {
|
if (!j$.isPromiseLike(actual)) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ getJasmineRequireObj().toBeResolved = function(j$) {
|
|||||||
* @example
|
* @example
|
||||||
* return expectAsync(aPromise).toBeResolved();
|
* return expectAsync(aPromise).toBeResolved();
|
||||||
*/
|
*/
|
||||||
return function toBeResolved(util) {
|
return function toBeResolved() {
|
||||||
return {
|
return {
|
||||||
compare: function(actual) {
|
compare: function(actual) {
|
||||||
if (!j$.isPromiseLike(actual)) {
|
if (!j$.isPromiseLike(actual)) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ getJasmineRequireObj().toBe = function(j$) {
|
|||||||
* @example
|
* @example
|
||||||
* expect(thing).toBe(realThing);
|
* expect(thing).toBe(realThing);
|
||||||
*/
|
*/
|
||||||
function toBe(util) {
|
function toBe(matchersUtil) {
|
||||||
var tip = ' Tip: To check for deep equality, use .toEqual() instead of .toBe().';
|
var tip = ' Tip: To check for deep equality, use .toEqual() instead of .toBe().';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -18,7 +18,7 @@ getJasmineRequireObj().toBe = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (typeof expected === 'object') {
|
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;
|
return result;
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ getJasmineRequireObj().toContain = function() {
|
|||||||
* expect(array).toContain(anElement);
|
* expect(array).toContain(anElement);
|
||||||
* expect(string).toContain(substring);
|
* expect(string).toContain(substring);
|
||||||
*/
|
*/
|
||||||
function toContain(util) {
|
function toContain(matchersUtil) {
|
||||||
return {
|
return {
|
||||||
compare: function(actual, expected) {
|
compare: function(actual, expected) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pass: util.contains(actual, expected)
|
pass: matchersUtil.contains(actual, expected)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,15 +8,15 @@ getJasmineRequireObj().toEqual = function(j$) {
|
|||||||
* @example
|
* @example
|
||||||
* expect(bigObject).toEqual({"foo": ['bar', 'baz']});
|
* expect(bigObject).toEqual({"foo": ['bar', 'baz']});
|
||||||
*/
|
*/
|
||||||
function toEqual(util) {
|
function toEqual(matchersUtil) {
|
||||||
return {
|
return {
|
||||||
compare: function(actual, expected) {
|
compare: function(actual, expected) {
|
||||||
var result = {
|
var result = {
|
||||||
pass: false
|
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
|
// TODO: only set error message if test fails
|
||||||
result.message = diffBuilder.getMessage();
|
result.message = diffBuilder.getMessage();
|
||||||
|
|||||||
Reference in New Issue
Block a user