Add tests for formatting empty content errors.

This commit is contained in:
Nito Buendia
2018-09-13 20:02:30 +08:00
parent b4cd1ec1ae
commit 04679622b0

View File

@@ -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(),