Failure messages for toHaveBeenCalledWith print out the name of the spy
This commit is contained in:
parent
32e736aa47
commit
dd32048383
@ -1318,13 +1318,13 @@ jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
|
|||||||
if (this.actual.callCount === 0) {
|
if (this.actual.callCount === 0) {
|
||||||
// todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw]
|
// todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw]
|
||||||
return [
|
return [
|
||||||
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
|
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
|
||||||
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was."
|
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was."
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
return [
|
return [
|
||||||
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall),
|
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall),
|
||||||
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall)
|
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -701,7 +701,7 @@ describe("jasmine.Matchers", function() {
|
|||||||
TestClass.spyFunction('d', 'e', 'f');
|
TestClass.spyFunction('d', 'e', 'f');
|
||||||
var expected = match(TestClass.spyFunction);
|
var expected = match(TestClass.spyFunction);
|
||||||
expect(expected.toHaveBeenCalledWith('a', 'b')).toFail();
|
expect(expected.toHaveBeenCalledWith('a', 'b')).toFail();
|
||||||
expect(lastResult().message).toEqual("Expected spy to have been called with [ 'a', 'b' ] but was called with [ [ 'a', 'b', 'c' ], [ 'd', 'e', 'f' ] ]");
|
expect(lastResult().message).toEqual("Expected spy My spy to have been called with [ 'a', 'b' ] but was called with [ [ 'a', 'b', 'c' ], [ 'd', 'e', 'f' ] ]");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return a decent message when inverted", function() {
|
it("should return a decent message when inverted", function() {
|
||||||
@ -709,7 +709,7 @@ describe("jasmine.Matchers", function() {
|
|||||||
TestClass.spyFunction('d', 'e', 'f');
|
TestClass.spyFunction('d', 'e', 'f');
|
||||||
var expected = match(TestClass.spyFunction);
|
var expected = match(TestClass.spyFunction);
|
||||||
expect(expected.not.toHaveBeenCalledWith('a', 'b', 'c')).toFail();
|
expect(expected.not.toHaveBeenCalledWith('a', 'b', 'c')).toFail();
|
||||||
expect(lastResult().message).toEqual("Expected spy not to have been called with [ 'a', 'b', 'c' ] but was called with [ [ 'a', 'b', 'c' ], [ 'd', 'e', 'f' ] ]");
|
expect(lastResult().message).toEqual("Expected spy My spy not to have been called with [ 'a', 'b', 'c' ] but was called with [ [ 'a', 'b', 'c' ], [ 'd', 'e', 'f' ] ]");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an exception when invoked on a non-spy', shouldThrowAnExceptionWhenInvokedOnANonSpy('toHaveBeenCalledWith'));
|
it('should throw an exception when invoked on a non-spy', shouldThrowAnExceptionWhenInvokedOnANonSpy('toHaveBeenCalledWith'));
|
||||||
|
@ -230,13 +230,13 @@ jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
|
|||||||
if (this.actual.callCount === 0) {
|
if (this.actual.callCount === 0) {
|
||||||
// todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw]
|
// todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw]
|
||||||
return [
|
return [
|
||||||
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
|
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
|
||||||
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was."
|
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was."
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
return [
|
return [
|
||||||
"Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall),
|
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall),
|
||||||
"Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall)
|
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user