simplify failure message logic in the toThrow matcher
This commit is contained in:
@@ -1364,7 +1364,7 @@ jasmine.Matchers.prototype.toThrow = function(expected) {
|
|||||||
var not = this.isNot ? "not " : "";
|
var not = this.isNot ? "not " : "";
|
||||||
|
|
||||||
this.message = function() {
|
this.message = function() {
|
||||||
if (exception && (jasmine.util.isUndefined(expected) || !this.env.equals_(exception.message || exception, expected.message || expected))) {
|
if (exception) {
|
||||||
return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
|
return ["Expected function " + not + "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.";
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ jasmine.Matchers.prototype.toThrow = function(expected) {
|
|||||||
var not = this.isNot ? "not " : "";
|
var not = this.isNot ? "not " : "";
|
||||||
|
|
||||||
this.message = function() {
|
this.message = function() {
|
||||||
if (exception && (jasmine.util.isUndefined(expected) || !this.env.equals_(exception.message || exception, expected.message || expected))) {
|
if (exception) {
|
||||||
return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
|
return ["Expected function " + not + "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.";
|
||||||
|
|||||||
Reference in New Issue
Block a user