1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add tests

This commit is contained in:
Dave Conway-Jones 2022-02-25 16:19:20 +00:00
parent 8c19daf949
commit bda5dffa34
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
2 changed files with 28 additions and 0 deletions

View File

@ -121,6 +121,19 @@ describe('TCP in Node', function() {
testTCP0(flow, ["foo\nbar"], ["foo", "bar"], done); testTCP0(flow, ["foo\nbar"], ["foo", "bar"], done);
}); });
it('should recv data (Stream/String/Delimiter:o\\n)', function(done) {
var flow = [{id:"n1", type:"tcp in", server:"server", host:"localhost", port:port, datamode:"stream", datatype:"utf8", newline:"o\n", topic:"", base64:false, wires:[["n2"]] },
{id:"n2", type:"helper"}];
testTCP0(flow, ["foo\nbar"], ["fo", "bar"], done);
});
it('should recv data (Stream/String/Delimiter:o\\n) and reattach o', function(done) {
var flow = [{id:"n1", type:"tcp in", server:"server", host:"localhost", port:port, datamode:"stream", datatype:"utf8", newline:"o\n", trim:true, topic:"", base64:false, wires:[["n2"]] },
{id:"n2", type:"helper"}];
testTCP0(flow, ["foo\nbar"], ["foo", "bar"], done);
});
it('should recv data (Stream/String/No delimiter)', function(done) { it('should recv data (Stream/String/No delimiter)', function(done) {
var flow = [{id:"n1", type:"tcp in", server:"server", host:"localhost", port:port, datamode:"stream", datatype:"utf8", newline:"", topic:"", base64:false, wires:[["n2"]] }, var flow = [{id:"n1", type:"tcp in", server:"server", host:"localhost", port:port, datamode:"stream", datatype:"utf8", newline:"", topic:"", base64:false, wires:[["n2"]] },
{id:"n2", type:"helper"}]; {id:"n2", type:"helper"}];

View File

@ -277,6 +277,21 @@ describe('TCP Request Node', function() {
}, { }, {
payload: "bar<A>\nfoo", payload: "bar<A>\nfoo",
topic: 'boo' topic: 'boo'
}], {
payload: "ACK:foobar",
topic: 'boo'
}, done);
});
it('should send & receive, then keep connection, and split return strings and reattach delimiter', function(done) {
var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"sit", ret:"string", newline:"<A>\\n", trim:true, wires:[["n2"]] },
{id:"n2", type:"helper"}];
testTCPMany(flow, [{
payload: "foo",
topic: 'boo'
}, {
payload: "bar<A>\nfoo",
topic: 'boo'
}], { }], {
payload: "ACK:foobar<A>", payload: "ACK:foobar<A>",
topic: 'boo' topic: 'boo'