mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
better tests
(and a small fix as a result)
This commit is contained in:
parent
02bd292b8c
commit
c9f03f1ac5
@ -86,7 +86,7 @@ module.exports = function(RED) {
|
|||||||
this.topic = n.topic;
|
this.topic = n.topic;
|
||||||
this.stream = (!n.datamode||n.datamode=='stream'); /* stream,single*/
|
this.stream = (!n.datamode||n.datamode=='stream'); /* stream,single*/
|
||||||
this.datatype = n.datatype||'buffer'; /* buffer,utf8,base64 */
|
this.datatype = n.datatype||'buffer'; /* buffer,utf8,base64 */
|
||||||
this.newline = (n.newline||"").replace("\\n","\n").replace("\\r","\r");
|
this.newline = (n.newline||"").replace("\\n","\n").replace("\\r","\r").replace("\\t","\t");
|
||||||
this.base64 = n.base64;
|
this.base64 = n.base64;
|
||||||
this.server = (typeof n.server == 'boolean')?n.server:(n.server == "server");
|
this.server = (typeof n.server == 'boolean')?n.server:(n.server == "server");
|
||||||
this.closing = false;
|
this.closing = false;
|
||||||
@ -517,7 +517,7 @@ module.exports = function(RED) {
|
|||||||
this.port = Number(n.port);
|
this.port = Number(n.port);
|
||||||
this.out = n.out;
|
this.out = n.out;
|
||||||
this.ret = n.ret || "buffer";
|
this.ret = n.ret || "buffer";
|
||||||
this.newline = n.newline;
|
this.newline = (n.newline||"").replace("\\n","\n").replace("\\r","\r").replace("\\t","\t");
|
||||||
this.splitc = n.splitc;
|
this.splitc = n.splitc;
|
||||||
if (n.tls) {
|
if (n.tls) {
|
||||||
var tlsNode = RED.nodes.getNode(n.tls);
|
var tlsNode = RED.nodes.getNode(n.tls);
|
||||||
|
@ -253,14 +253,32 @@ describe('TCP Request Node', function() {
|
|||||||
}, done);
|
}, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send & receive, then keep connection, and split return strings', function(done) {
|
it('should send & receive, then keep connection, and not split return strings', function(done) {
|
||||||
var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"sit", ret:"string", newline:"<A>", wires:[["n2"]] },
|
var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"sit", ret:"string", newline:"", wires:[["n2"]] },
|
||||||
{id:"n2", type:"helper"}];
|
{id:"n2", type:"helper"}];
|
||||||
testTCPMany(flow, [{
|
testTCPMany(flow, [{
|
||||||
payload: "foo<A>bar",
|
payload: "foo",
|
||||||
|
topic: 'boo'
|
||||||
|
}, {
|
||||||
|
payload: "bar<A>\nfoo",
|
||||||
topic: 'boo'
|
topic: 'boo'
|
||||||
}], {
|
}], {
|
||||||
payload: "ACK:foo<A>",
|
payload: "ACK:foobar<A>\nfoo",
|
||||||
|
topic: 'boo'
|
||||||
|
}, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should send & receive, then keep connection, and split return strings', function(done) {
|
||||||
|
var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"sit", ret:"string", newline:"<A>\\n", wires:[["n2"]] },
|
||||||
|
{id:"n2", type:"helper"}];
|
||||||
|
testTCPMany(flow, [{
|
||||||
|
payload: "foo",
|
||||||
|
topic: 'boo'
|
||||||
|
}, {
|
||||||
|
payload: "bar<A>\nfoo",
|
||||||
|
topic: 'boo'
|
||||||
|
}], {
|
||||||
|
payload: "ACK:foobar<A>",
|
||||||
topic: 'boo'
|
topic: 'boo'
|
||||||
}, done);
|
}, done);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user