diff --git a/spec/core/ExceptionFormatterSpec.js b/spec/core/ExceptionFormatterSpec.js index 346d4c2a..9cc3638b 100644 --- a/spec/core/ExceptionFormatterSpec.js +++ b/spec/core/ExceptionFormatterSpec.js @@ -37,7 +37,7 @@ describe("ExceptionFormatter", function() { expect(message).toEqual('A Classic Mistake: you got your foo in my bar'); }); - it('formats thrown exceptions with message but no name', function() { + it('formats unnamed exceptions with message', function() { var unnamedError = {message: 'This is an unnamed error message.'}; var exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(), @@ -46,6 +46,19 @@ describe("ExceptionFormatter", function() { expect(message).toEqual('This is an unnamed error message.'); }); + it('formats empty exceptions with toString format', function() { + var EmptyError = function() {}; + EmptyError.prototype.toString = function() { + return '[EmptyError]'; + }; + var emptyError = new EmptyError(); + + var exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(), + message = exceptionFormatter.message(emptyError); + + expect(message).toEqual('[EmptyError] thrown'); + }); + it("formats thrown exceptions that aren't errors", function() { var thrown = "crazy error", exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),