Explicitly test pretty printing objects with nested invalid toString

This commit is contained in:
Elliot Nelson
2019-05-20 09:09:07 -04:00
parent 9f704b6f3a
commit 8225bb935f

View File

@@ -344,8 +344,12 @@ describe("jasmineUnderTest.pp", function () {
}, },
bar: { bar: {
toString: function() { toString: function() {
// Invalid: toString returning an object // Really invalid: a nested bad toString().
return new Error("bar"); return {
toString: function() {
return new Date();
}
};
} }
}, },
// Valid: an actual number // Valid: an actual number
@@ -354,6 +358,6 @@ describe("jasmineUnderTest.pp", function () {
qux: new Error("bar") qux: new Error("bar")
}; };
expect(jasmineUnderTest.pp(obj)).toEqual("Object({ foo: [object Number], bar: [object Error], baz: 3, qux: Error: bar })"); expect(jasmineUnderTest.pp(obj)).toEqual("Object({ foo: [object Number], bar: [object Object], baz: 3, qux: Error: bar })");
}); });
}); });