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

add test for env var access of GROUP_ID & GROUP_NAME

This commit is contained in:
Hiroyasu Nishiyama 2022-01-25 21:07:38 +09:00
parent 8b23d341b4
commit 983dad5b53

View File

@ -182,6 +182,47 @@ describe('inject node', function() {
}); });
}); });
it('inject name of group as environment variable ', function (done) {
var flow = [{id: "n1", type: "inject", name: "NAME", topnic: "t1", payload: "GROUP_NAME", payloadType: "env", wires: [["n2"]], z: "flow", g: "g0"},
{id: "n2", type: "helper"},
{id: "g0", type: "group", name: "GROUP" },
];
helper.load(injectNode, flow, function () {
var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2");
n2.on("input", function (msg) {
try {
msg.should.have.property("payload", "GROUP");
done();
} catch (err) {
done(err);
}
});
n1.receive({});
});
});
it('inject id of group as environment variable ', function (done) {
var flow = [{id: "n1", type: "inject", name: "NAME", topnic: "t1", payload: "GROUP_ID", payloadType: "env", wires: [["n2"]], z: "flow", g: "g0"},
{id: "n2", type: "helper"},
{id: "g0", type: "group", name: "GROUP" },
];
helper.load(injectNode, flow, function () {
var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2");
n2.on("input", function (msg) {
try {
msg.should.have.property("payload", "g0");
done();
} catch (err) {
done(err);
}
});
n1.receive({});
});
});
it('sets the value of flow context property', function (done) { it('sets the value of flow context property', function (done) {
var flow = [{id: "n1", type: "inject", topic: "t1", payload: "flowValue", payloadType: "flow", wires: [["n2"]], z: "flow"}, var flow = [{id: "n1", type: "inject", topic: "t1", payload: "flowValue", payloadType: "flow", wires: [["n2"]], z: "flow"},
{id: "n2", type: "helper"}]; {id: "n2", type: "helper"}];