Merge branch 'dev' into pr_2165

This commit is contained in:
Nick O'Leary
2019-07-10 09:30:48 +01:00
282 changed files with 4009 additions and 1538 deletions

View File

@@ -979,6 +979,29 @@ describe('HTTP Request Node', function() {
n1.receive({payload:"foo", requestTimeout: -4});
});
});
it('should show a warning if msg.requestTimeout is set to 0', function(done) {
var flow = [{id:"n1",type:"http request",wires:[["n2"]],method:"GET",ret:"obj",url:getTestURL('/text')},
{id:"n2", type:"helper"}];
helper.load(httpRequestNode, flow, function() {
var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2");
n2.on("input", function(msg) {
try {
msg.should.have.property('statusCode', 200);
var logEvents = helper.log().args.filter(function(evt) {
return evt[0].type == 'http request';
});
logEvents.should.have.length(2);
var tstmp = logEvents[0][0].timestamp;
logEvents[0][0].should.eql({level:helper.log().WARN, id:'n1',type:'http request',msg:'httpin.errors.timeout-isnegative', timestamp:tstmp});
done();
} catch(err) {
done(err);
}
});
n1.receive({payload:"foo", requestTimeout: 0});
});
});
it('should pass if response time is faster than timeout set via msg.requestTimeout', function(done) {
var flow = [{id:"n1",type:"http request",wires:[["n2"]],method:"GET",ret:"obj",url:getTestURL('/timeout50ms')},
{id:"n2", type:"helper"}];
@@ -1268,6 +1291,7 @@ describe('HTTP Request Node', function() {
var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2");
n2.on("input", function(msg) {
console.log(msg.payload);
try {
msg.payload.headers.should.have.property('content-type').which.startWith('application/json');
msg.payload.headers.should.not.have.property('x-node-red-request-node');
@@ -1278,7 +1302,11 @@ describe('HTTP Request Node', function() {
});
// Pass in a headers property with an unmodified x-node-red-request-node hash
// This should cause the node to ignore the headers
n1.receive({payload:{foo:"bar"}, headers: { 'content-type': 'text/plain', "x-node-red-request-node":"67690139"}});
var headers = { 'content-type': 'text/plain' };
headers['x-node-red-request-node'] = require("hash-sum")(headers);
n1.receive({payload:{foo:"bar"}, headers: headers});
});
});

View File

@@ -179,6 +179,24 @@ describe('websocket Node', function() {
});
});
it('should receive wholemsg when data not object', function(done) {
var flow = [
{ id: "n1", type: "websocket-listener", path: "/ws", wholemsg: "true" },
{ id: "n2", type: "websocket in", server: "n1", wires: [["n3"]] },
{ id: "n3", type: "helper" }];
helper.load(websocketNode, flow, function() {
createClient("n1").then(function(sock) {
helper.getNode("n3").on("input", function(msg) {
msg.should.have.property("payload", 123);
done();
});
sock.send(123);
}).catch(function(err) {
done(err);
});
});
});
it('should send', function(done) {
var flow = [
{ id: "n1", type: "websocket-listener", path: "/ws" },

View File

@@ -818,6 +818,14 @@ describe('switch Node', function() {
});
});
it('should handle env var expression', function(done) {
var flow = [{id:"switchNode1",type:"switch",name:"switchNode",property:"VAR",propertyType:"env",rules:[{"t":"eq","v":"VAL"}],checkall:true,outputs:1,wires:[["helperNode1"]]},
{id:"helperNode1", type:"helper", wires:[]}];
process.env.VAR = "VAL";
customFlowSwitchTest(flow, true, "OK", done);
});
it('should take head of message sequence (no repair)', function(done) {
var flow = [{id:"switchNode1",type:"switch",name:"switchNode",property:"payload",rules:[{"t":"head","v":3}],checkall:false,repair:false,outputs:1,wires:[["helperNode1"]]},
{id:"helperNode1", type:"helper", wires:[]}];

View File

@@ -677,6 +677,9 @@ describe('JOIN node', function() {
n1.receive({payload:{f:1}, topic:"f", complete:true});
n1.receive({payload:{g:2}, topic:"g"});
n1.receive({payload:{h:1}, topic:"h"});
n1.receive({reset:true});
n1.receive({payload:{g:2}, topic:"g"});
n1.receive({payload:{h:1}, topic:"h"});
n1.receive({payload:{i:3}, topic:"i"});
});
});
@@ -700,6 +703,9 @@ describe('JOIN node', function() {
}
catch(e) { done(e) }
});
n1.receive({payload:2, foo:"b"});
n1.receive({payload:3, foo:"c"});
n1.receive({reset:true});
n1.receive({payload:1, foo:"a"});
n1.receive({payload:2, foo:"b"});
n1.receive({payload:3, foo:"c"});