Add tests for formatting empty content errors.
This commit is contained in:
@@ -37,7 +37,7 @@ describe("ExceptionFormatter", function() {
|
|||||||
expect(message).toEqual('A Classic Mistake: you got your foo in my bar');
|
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 unnamedError = {message: 'This is an unnamed error message.'};
|
||||||
|
|
||||||
var exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
var exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
||||||
@@ -46,6 +46,19 @@ describe("ExceptionFormatter", function() {
|
|||||||
expect(message).toEqual('This is an unnamed error message.');
|
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() {
|
it("formats thrown exceptions that aren't errors", function() {
|
||||||
var thrown = "crazy error",
|
var thrown = "crazy error",
|
||||||
exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
exceptionFormatter = new jasmineUnderTest.ExceptionFormatter(),
|
||||||
|
|||||||
Reference in New Issue
Block a user