2026-02-19 17:37:42 +01:00
|
|
|
const test = require('node:test');
|
|
|
|
|
const assert = require('node:assert/strict');
|
|
|
|
|
|
|
|
|
|
const NodeClass = require('../../src/nodeClass');
|
2026-05-10 22:23:43 +02:00
|
|
|
const commands = require('../../src/commands');
|
|
|
|
|
const { createRegistry } = require('generalFunctions');
|
2026-02-19 17:37:42 +01:00
|
|
|
const { makeNodeStub, makeREDStub } = require('../helpers/factories');
|
|
|
|
|
|
2026-05-10 22:23:43 +02:00
|
|
|
test('unknown input topic does not throw and still calls done', async () => {
|
2026-02-19 17:37:42 +01:00
|
|
|
const inst = Object.create(NodeClass.prototype);
|
|
|
|
|
const node = makeNodeStub();
|
|
|
|
|
|
|
|
|
|
inst.node = node;
|
|
|
|
|
inst.RED = makeREDStub();
|
|
|
|
|
inst.source = {
|
2026-05-10 22:23:43 +02:00
|
|
|
logger: { warn: () => {}, info: () => {}, debug: () => {}, error: () => {} },
|
|
|
|
|
childRegistrationUtils: { registerChild() {} },
|
2026-02-19 17:37:42 +01:00
|
|
|
updateState() {},
|
|
|
|
|
};
|
2026-05-10 22:23:43 +02:00
|
|
|
inst._commands = createRegistry(commands, { logger: inst.source.logger });
|
2026-02-19 17:37:42 +01:00
|
|
|
inst._attachInputHandler();
|
|
|
|
|
|
|
|
|
|
let doneCalled = 0;
|
2026-05-10 22:23:43 +02:00
|
|
|
await assert.doesNotReject(async () => {
|
|
|
|
|
await node._handlers.input({ topic: 'somethingUnknown', payload: 1 }, () => {}, () => {
|
2026-02-19 17:37:42 +01:00
|
|
|
doneCalled += 1;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
assert.equal(doneCalled, 1);
|
|
|
|
|
});
|