From 765f0393b068857592e77741bd3004ca61af18c6 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Sun, 28 Aug 2016 12:09:37 +0100 Subject: [PATCH] Add test for change node ,move to sub-property --- test/nodes/core/logic/15-change_spec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/nodes/core/logic/15-change_spec.js b/test/nodes/core/logic/15-change_spec.js index f9564d749..2be1c0262 100644 --- a/test/nodes/core/logic/15-change_spec.js +++ b/test/nodes/core/logic/15-change_spec.js @@ -670,6 +670,25 @@ describe('change Node', function() { changeNode1.receive({topic:{foo:{bar:1}}, payload:"String"}); }); }); + it('moves the value of a message property object to a sub-property', function(done) { + var flow = [{"id":"changeNode1","type":"change","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.foo","tot":"msg"}],"name":"changeNode","wires":[["helperNode1"]]}, + {id:"helperNode1", type:"helper", wires:[]}]; + helper.load(changeNode, flow, function() { + var changeNode1 = helper.getNode("changeNode1"); + var helperNode1 = helper.getNode("helperNode1"); + helperNode1.on("input", function(msg) { + try { + msg.should.have.property('payload'); + msg.payload.should.have.property('foo'); + msg.payload.foo.should.equal("bar"); + done(); + } catch(err) { + done(err); + } + }); + changeNode1.receive({payload:"bar"}); + }); + }); }); describe('- multiple rules', function() {