mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Resync with master
This commit is contained in:
@@ -166,6 +166,18 @@ describe('template node', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle block contexts objects', function(done) {
|
||||
var flow = [{id:"n1", type:"template", template: "A{{#payload.A}}{{payload.A}}{{.}}{{/payload.A}}B",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.should.have.property('payload','AabcabcB');
|
||||
done();
|
||||
});
|
||||
n1.receive({payload:{A:"abc"}});
|
||||
});
|
||||
});
|
||||
it('should raise error if passed bad template', function(done) {
|
||||
var flow = [{id:"n1", type:"template", field: "payload", template: "payload={{payload",wires:[["n2"]]},{id:"n2",type:"helper"}];
|
||||
helper.load(templateNode, flow, function() {
|
||||
|
@@ -514,7 +514,7 @@ describe("red/nodes/registry/loader",function() {
|
||||
node.enabled.should.be.true();
|
||||
nodes.registerType.called.should.be.false();
|
||||
node.should.have.property('err');
|
||||
node.err.message.should.eql("fail to require");
|
||||
node.err.toString().should.eql("Error: fail to require (line:1)");
|
||||
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
@@ -564,6 +564,45 @@ describe("red/nodes/registry/loader",function() {
|
||||
loader.getNodeHelp(node,"fr").should.eql("foo");
|
||||
fs.readFileSync.calledOnce.should.be.true();
|
||||
});
|
||||
it("loads help, defaulting to en-US content for extra nodes", function() {
|
||||
stubs.push(sinon.stub(fs,"readFileSync", function(path) {
|
||||
if (path.indexOf("en-US") >= 0) {
|
||||
return 'bar';
|
||||
}
|
||||
throw new Error("not found");
|
||||
}));
|
||||
var node = {
|
||||
template: "/tmp/node/directory/file.html",
|
||||
help:{}
|
||||
};
|
||||
delete node.help['en-US'];
|
||||
|
||||
loader.getNodeHelp(node,"fr").should.eql("bar");
|
||||
node.help['fr'].should.eql("bar");
|
||||
fs.readFileSync.calledTwice.should.be.true();
|
||||
fs.readFileSync.firstCall.args[0].should.eql(path.normalize("/tmp/node/directory/locales/fr/file.html"));
|
||||
fs.readFileSync.lastCall.args[0].should.eql(path.normalize("/tmp/node/directory/locales/en-US/file.html"));
|
||||
loader.getNodeHelp(node,"fr").should.eql("bar");
|
||||
fs.readFileSync.calledTwice.should.be.true();
|
||||
});
|
||||
it("fails to load en-US help content", function() {
|
||||
stubs.push(sinon.stub(fs,"readFileSync", function(path) {
|
||||
throw new Error("not found");
|
||||
}));
|
||||
var node = {
|
||||
template: "/tmp/node/directory/file.html",
|
||||
help:{}
|
||||
};
|
||||
delete node.help['en-US'];
|
||||
|
||||
should.not.exist(loader.getNodeHelp(node,"en-US"));
|
||||
should.not.exist(node.help['en-US']);
|
||||
fs.readFileSync.calledTwice.should.be.true();
|
||||
fs.readFileSync.firstCall.args[0].should.eql(path.normalize("/tmp/node/directory/locales/en-US/file.html"));
|
||||
fs.readFileSync.lastCall.args[0].should.eql(path.normalize("/tmp/node/directory/locales/en/file.html"));
|
||||
should.not.exist(loader.getNodeHelp(node,"en-US"));
|
||||
fs.readFileSync.callCount.should.eql(4);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user