Merge branch 'logankd-master'
- Support call count of 0 with toHaveBeenCalledTimes matcher - Merges #1048 - Fixes #994
This commit is contained in:
@@ -3138,8 +3138,8 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
||||
var args = Array.prototype.slice.call(arguments, 0),
|
||||
result = { pass: false };
|
||||
|
||||
if(!expected){
|
||||
throw new Error('Expected times failed is required as an argument.');
|
||||
if (!j$.isNumber_(expected)){
|
||||
throw new Error('The expected times failed is a required argument and must be a number.');
|
||||
}
|
||||
|
||||
actual = args[0];
|
||||
@@ -3156,7 +3156,6 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
||||
|
||||
return toHaveBeenCalledTimes;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
||||
|
||||
function toHaveBeenCalledWith(util, customEqualityTesters) {
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
describe("toHaveBeenCalledTimes", function() {
|
||||
it("passes when the actual 0 matches the expected 0 ", function () {
|
||||
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||
calledSpy = jasmineUnderTest.createSpy('called-spy'),
|
||||
result;
|
||||
result = matcher.compare(calledSpy, 0);
|
||||
expect(result.pass).toBeTruthy();
|
||||
});
|
||||
it("passes when the actual matches the expected", function() {
|
||||
var matcher = jasmineUnderTest.matchers.toHaveBeenCalledTimes(),
|
||||
calledSpy = jasmineUnderTest.createSpy('called-spy'),
|
||||
@@ -17,7 +24,7 @@ describe("toHaveBeenCalledTimes", function() {
|
||||
spy();
|
||||
expect(function() {
|
||||
matcher.compare(spy);
|
||||
}).toThrowError('Expected times failed is required as an argument.');
|
||||
}).toThrowError('The expected times failed is a required argument and must be a number.');
|
||||
});
|
||||
|
||||
it("fails when the actual was called less than the expected", function() {
|
||||
@@ -60,7 +67,6 @@ describe("toHaveBeenCalledTimes", function() {
|
||||
spy();
|
||||
|
||||
result = matcher.compare(spy, 1);
|
||||
|
||||
expect(result.message).toEqual('Expected spy sample-spy to have been called once. It was called ' + 4 + ' times.');
|
||||
});
|
||||
|
||||
@@ -74,7 +80,6 @@ describe("toHaveBeenCalledTimes", function() {
|
||||
spy();
|
||||
|
||||
result = matcher.compare(spy, 2);
|
||||
|
||||
expect(result.message).toEqual('Expected spy sample-spy to have been called 2 times. It was called ' + 4 + ' times.');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,8 +10,8 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
||||
var args = Array.prototype.slice.call(arguments, 0),
|
||||
result = { pass: false };
|
||||
|
||||
if(!expected){
|
||||
throw new Error('Expected times failed is required as an argument.');
|
||||
if (!j$.isNumber_(expected)){
|
||||
throw new Error('The expected times failed is a required argument and must be a number.');
|
||||
}
|
||||
|
||||
actual = args[0];
|
||||
@@ -27,4 +27,4 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
||||
}
|
||||
|
||||
return toHaveBeenCalledTimes;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user