Allow string templates to handle null objects without failing
This commit is contained in:
parent
a9eb15e925
commit
7e082a18d8
|
@ -16,9 +16,6 @@ registerAll(hbsInstance)
|
|||
* utility function to check if the object is valid
|
||||
*/
|
||||
function testObject(object) {
|
||||
if (object == null) {
|
||||
throw "Unable to process null object"
|
||||
}
|
||||
// JSON stringify will fail if there are any cycles, stops infinite recursion
|
||||
try {
|
||||
JSON.stringify(object)
|
||||
|
|
|
@ -81,14 +81,14 @@ describe("Test that the object processing works correctly", () => {
|
|||
expect(error).not.toBeNull()
|
||||
})
|
||||
|
||||
it("should fail gracefully when wrong type is passed in", async () => {
|
||||
it("should be able to handle null objects", async () => {
|
||||
let error = null
|
||||
try {
|
||||
await processObject(null, null)
|
||||
} catch (err) {
|
||||
error = err
|
||||
}
|
||||
expect(error).not.toBeNull()
|
||||
expect(error).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue