From c54509df3d31f8a4808bda23d27946c734e70bff Mon Sep 17 00:00:00 2001 From: Simon Hailes Date: Sat, 2 Nov 2019 13:03:37 +0000 Subject: [PATCH] additional test to cover last line in encodeObject --- test/unit/@node-red/util/lib/util_spec.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/test/unit/@node-red/util/lib/util_spec.js b/test/unit/@node-red/util/lib/util_spec.js index b3f9fe57d..cf59df55e 100644 --- a/test/unit/@node-red/util/lib/util_spec.js +++ b/test/unit/@node-red/util/lib/util_spec.js @@ -842,7 +842,7 @@ describe("@node-red/util/util", function() { }; for (var i = 0; i < 1000; i++) { - msg.msg.obj.big += 'some more string '; + msg.msg.obj.big += 'some more string '; } var result = util.encodeObject(msg); @@ -855,11 +855,11 @@ describe("@node-red/util/util", function() { it('test bad toString', function(done) { var msg = { msg: { - mystrangeobj:"hello", + mystrangeobj:"hello", }, }; msg.msg.toString = function(){ - throw new Error('Exception in toString - should have been caught'); + throw new Error('Exception in toString - should have been caught'); } msg.msg.constructor = { name: "strangeobj" }; @@ -868,8 +868,21 @@ describe("@node-red/util/util", function() { success.should.eql(true); done(); }); + it('test bad object constructor', function(done) { + var msg = { + msg: { + mystrangeobj:"hello", + constructor: { + get name(){ + throw new Error('Exception in constructor name'); + } + } + }, + }; + var result = util.encodeObject(msg); + done(); + }); - }); }); });