Handle escape characters in template node which uses Mustache format and JSON output mode (#1377)

* Handle escape characters in template node which uses Mustache format and JSON output mode

* Handle escape characters in template node which uses Mustache format and JSON output mode
This commit is contained in:
Kazuhito Yokoi
2017-09-21 21:38:45 +09:00
committed by Nick O'Leary
parent 6ce761edda
commit ef53dca062
2 changed files with 27 additions and 2 deletions

View File

@@ -88,6 +88,18 @@ describe('template node', function() {
});
});
it('should handle escape characters in Mustache format and JSON output mode', function(done) {
var flow = [{id:"n1", type:"template", field:"payload", syntax:"mustache", template:"{\"data\":\"{{payload}}\"}", output:"json", wires:[["n2"]]},{id:"n2",type:"helper"}];
helper.load(templateNode, flow, function() {
var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2");
n2.on("input", function(msg) {
msg.payload.should.have.property('data', 'line\t1\nline\\2\r\nline\b3\f');
done();
});
n1.receive({payload:"line\t1\nline\\2\r\nline\b3\f"});
});
});
it('should modify payload in plain text mode', function(done) {
var flow = [{id:"n1", type:"template", field:"payload", syntax:"plain", template:"payload={{payload}}",wires:[["n2"]]},{id:"n2",type:"helper"}];