mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Move cloneMessage to RED.util.cloneMessage
This commit is contained in:
@@ -66,5 +66,35 @@ describe("red/util", function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('cloneMessage', function() {
|
||||
it('clones a simple message', function() {
|
||||
var msg = {string:"hi",array:[1,2,3],object:{a:1,subobject:{b:2}}};
|
||||
|
||||
var cloned = util.cloneMessage(msg);
|
||||
|
||||
cloned.should.eql(msg);
|
||||
|
||||
cloned.should.not.equal(msg);
|
||||
cloned.array.should.not.equal(msg.string);
|
||||
cloned.object.should.not.equal(msg.object);
|
||||
cloned.object.subobject.should.not.equal(msg.object.subobject);
|
||||
|
||||
cloned.should.not.have.property("req");
|
||||
cloned.should.not.have.property("res");
|
||||
});
|
||||
it('does not clone http req/res properties', function() {
|
||||
var msg = {req:{a:1},res:{b:2}};
|
||||
|
||||
var cloned = util.cloneMessage(msg);
|
||||
|
||||
cloned.should.eql(msg);
|
||||
cloned.should.not.equal(msg);
|
||||
|
||||
cloned.req.should.equal(msg.req);
|
||||
cloned.res.should.equal(msg.res);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user