Fix not.toThrow() matcher exception when used with no args.
This commit is contained in:
parent
89afebd86b
commit
4d7b839473
@ -457,7 +457,10 @@ describe("jasmine.Matchers", function() {
|
|||||||
var expected = match(function() {
|
var expected = match(function() {
|
||||||
throw new Error("Fake Error");
|
throw new Error("Fake Error");
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(expected.toThrow()).toEqual(true);
|
expect(expected.toThrow()).toEqual(true);
|
||||||
|
expect(expected.not.toThrow()).toEqual(false);
|
||||||
|
|
||||||
expect(expected.toThrow("Fake Error")).toEqual(true);
|
expect(expected.toThrow("Fake Error")).toEqual(true);
|
||||||
expect(expected.toThrow(new Error("Fake Error"))).toEqual(true);
|
expect(expected.toThrow(new Error("Fake Error"))).toEqual(true);
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ jasmine.Matchers.prototype.toThrow = function(expected) {
|
|||||||
|
|
||||||
this.message = function() {
|
this.message = function() {
|
||||||
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
|
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
|
||||||
return ["Expected function to throw", expected.message || expected, ", but it threw", exception.message || exception].join(' ');
|
return ["Expected function to throw", expected ? expected.message || expected : " an exception", ", but it threw", exception.message || exception].join(' ');
|
||||||
} else {
|
} else {
|
||||||
return "Expected function to throw an exception.";
|
return "Expected function to throw an exception.";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user