1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00
node-red/test/unit/@node-red/runtime/lib/flows/Group_spec.js

49 lines
1.5 KiB
JavaScript
Raw Normal View History

const should = require("should");
const NR_TEST_UTILS = require("nr-test-utils");
const { Group } = NR_TEST_UTILS.require("@node-red/runtime/lib/flows/Group");
describe('Group', function () {
describe('getSetting', function () {
it("returns group name/id", async function () {
const group = new Group({
getSetting: v => v+v
}, {
name: "g1",
id: "group1"
})
await group.start()
group.getSetting("NR_GROUP_NAME").should.equal("g1")
group.getSetting("NR_GROUP_ID").should.equal("group1")
})
it("delegates to parent if not found", async function () {
const group = new Group({
getSetting: v => v+v
}, {
name: "g1",
id: "group1"
})
await group.start()
group.getSetting("123").should.equal("123123")
})
it("delegates to parent if explicit requested", async function () {
const parentGroup = new Group({
getSetting: v => v+v
}, {
name: "g0",
id: "group0"
})
const group = new Group(parentGroup, {
name: "g1",
id: "group1"
})
await parentGroup.start()
await group.start()
group.getSetting("$parent.NR_GROUP_NAME").should.equal("g0")
group.getSetting("$parent.NR_GROUP_ID").should.equal("group0")
})
})
})