mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge branch '0.19' into runtime-api
This commit is contained in:
@@ -524,7 +524,7 @@ describe('function node', function() {
|
||||
|
||||
it('should allow accessing node.name', function(done) {
|
||||
var flow = [{id:"n1",type:"function",wires:[["n2"]],func:"msg.payload = node.name; return msg;", "name":"name of node"},
|
||||
{id:"n2", type:"helper"}];
|
||||
{id:"n2", type:"helper"}];
|
||||
helper.load(functionNode, flow, function() {
|
||||
var n1 = helper.getNode("n1");
|
||||
var n2 = helper.getNode("n2");
|
||||
@@ -536,6 +536,21 @@ describe('function node', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should use the same Date object from outside the sandbox', function(done) {
|
||||
var flow = [{id:"n1",type:"function",wires:[["n2"]],func:"msg.payload=global.get('typeTest')(new Date());return msg;"},
|
||||
{id:"n2", type:"helper"}];
|
||||
helper.load(functionNode, flow, function() {
|
||||
var n1 = helper.getNode("n1");
|
||||
var n2 = helper.getNode("n2");
|
||||
n1.context().global.set("typeTest",function(d) { return d instanceof Date });
|
||||
n2.on("input", function(msg) {
|
||||
msg.should.have.property('payload', true);
|
||||
done();
|
||||
});
|
||||
n1.receive({payload:"foo",topic: "bar"});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Logger', function () {
|
||||
it('should log an Info Message', function (done) {
|
||||
var flow = [{id: "n1", type: "function", wires: [["n2"]], func: "node.log('test');"}];
|
||||
|
@@ -428,13 +428,14 @@ describe('trigger node', function() {
|
||||
n2.on("input", function(msg) {
|
||||
try {
|
||||
if (c === 0) {
|
||||
console.log(c,Date.now() - ss,msg);
|
||||
msg.should.have.a.property("payload", "Hello");
|
||||
c += 1;
|
||||
}
|
||||
else {
|
||||
console.log(c,Date.now() - ss,msg);
|
||||
msg.should.have.a.property("payload", "World");
|
||||
//console.log(Date.now() - ss);
|
||||
(Date.now() - ss).should.be.greaterThan(140);
|
||||
(Date.now() - ss).should.be.greaterThan(150);
|
||||
done();
|
||||
}
|
||||
}
|
||||
@@ -444,7 +445,7 @@ describe('trigger node', function() {
|
||||
n1.emit("input", {payload:"Hello"});
|
||||
setTimeout( function() {
|
||||
n1.emit("input", {payload:"Error"});
|
||||
},20);
|
||||
},30);
|
||||
setTimeout( function() {
|
||||
n1.emit("input", {payload:"World"});
|
||||
},150);
|
||||
|
@@ -796,6 +796,25 @@ describe('HTTP Request Node', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should prevent following redirect when msg.followRedirects is false', function(done) {
|
||||
var flow = [{id:"n1",type:"http request",wires:[["n2"]],method:"GET",ret:"txt",url:getTestURL('/redirectToText')},
|
||||
{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',302);
|
||||
msg.should.have.property('responseUrl', getTestURL('/redirectToText'));
|
||||
done();
|
||||
} catch(err) {
|
||||
done(err);
|
||||
}
|
||||
});
|
||||
n1.receive({payload:"foo",followRedirects:false});
|
||||
});
|
||||
});
|
||||
|
||||
it('shuold output an error when request timeout occurred', function(done) {
|
||||
var flow = [{id:"n1",type:"http request",wires:[["n2"]],method:"GET",ret:"obj",url:getTestURL('/timeout')},
|
||||
{id:"n2", type:"helper"}];
|
||||
@@ -806,7 +825,13 @@ describe('HTTP Request Node', function() {
|
||||
var n2 = helper.getNode("n2");
|
||||
n2.on("input", function(msg) {
|
||||
try {
|
||||
msg.should.have.property('statusCode','ECONNRESET');
|
||||
msg.should.have.property('statusCode','ESOCKETTIMEDOUT');
|
||||
var logEvents = helper.log().args.filter(function(evt) {
|
||||
return evt[0].type == 'http request';
|
||||
});
|
||||
logEvents.should.have.length(1);
|
||||
var tstmp = logEvents[0][0].timestamp;
|
||||
logEvents[0][0].should.eql({level:helper.log().ERROR, id:'n1',type:'http request',msg:'common.notification.errors.no-response', timestamp:tstmp});
|
||||
done();
|
||||
} catch(err) {
|
||||
done(err);
|
||||
|
@@ -197,8 +197,7 @@ describe("api/auth/users", function() {
|
||||
it('should fail to return user fred',function(done) {
|
||||
Users.get("fred").then(function(userf) {
|
||||
try {
|
||||
userf.should.not.have.a.property("username","fred");
|
||||
userf.should.not.have.a.property("permissions","*");
|
||||
should.not.exist(userf);
|
||||
done();
|
||||
} catch(err) {
|
||||
done(err);
|
||||
@@ -215,6 +214,9 @@ describe("api/auth/users", function() {
|
||||
default: function() { return("Done"); }
|
||||
});
|
||||
});
|
||||
after(function() {
|
||||
Users.init({});
|
||||
});
|
||||
describe('#default',function() {
|
||||
it('handles api.default being a function',function(done) {
|
||||
Users.should.have.property('default').which.is.a.Function();
|
||||
|
@@ -540,7 +540,7 @@ describe("red/nodes/registry/registry",function() {
|
||||
}
|
||||
},icons: [{path:testIcon,icons:['test_icon.png']}]});
|
||||
var iconPath = typeRegistry.getNodeIconPath('test-module','test_icon.png');
|
||||
iconPath.should.eql(testIcon+"/test_icon.png");
|
||||
iconPath.should.eql(path.resolve(testIcon+"/test_icon.png"));
|
||||
});
|
||||
|
||||
it('returns the debug icon when getting an unknown module', function() {
|
||||
|
@@ -19,6 +19,13 @@ var should = require("should");
|
||||
var defaultFileSet = require("../../../../../../red/runtime/storage/localfilesystem/projects/defaultFileSet");
|
||||
|
||||
describe('storage/localfilesystem/projects/defaultFileSet', function() {
|
||||
var runtime = {
|
||||
i18n: {
|
||||
"_": function(name) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
};
|
||||
it('generates package.json for a project', function() {
|
||||
var generated = defaultFileSet["package.json"]({
|
||||
name: "A TEST NAME",
|
||||
@@ -27,7 +34,7 @@ describe('storage/localfilesystem/projects/defaultFileSet', function() {
|
||||
flow: "MY FLOW FILE",
|
||||
credentials: "MY CREDENTIALS FILE"
|
||||
}
|
||||
});
|
||||
}, runtime);
|
||||
|
||||
var parsed = JSON.parse(generated);
|
||||
parsed.should.have.property('name',"A TEST NAME");
|
||||
@@ -42,7 +49,7 @@ describe('storage/localfilesystem/projects/defaultFileSet', function() {
|
||||
var generated = defaultFileSet["README.md"]({
|
||||
name: "A TEST NAME",
|
||||
summary: "A TEST SUMMARY"
|
||||
});
|
||||
}, runtime);
|
||||
generated.should.match(/A TEST NAME/);
|
||||
generated.should.match(/A TEST SUMMARY/);
|
||||
});
|
||||
@@ -50,7 +57,7 @@ describe('storage/localfilesystem/projects/defaultFileSet', function() {
|
||||
var generated = defaultFileSet[".gitignore"]({
|
||||
name: "A TEST NAME",
|
||||
summary: "A TEST SUMMARY"
|
||||
});
|
||||
}, runtime);
|
||||
generated.length.should.be.greaterThan(0);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user