Files
reactor/test/edge/invalid-topic.edge.test.js

32 lines
1.0 KiB
JavaScript
Raw Normal View History

2026-02-19 17:37:42 +01:00
const test = require('node:test');
const assert = require('node:assert/strict');
const NodeClass = require('../../src/nodeClass');
const commands = require('../../src/commands');
const { createRegistry } = require('generalFunctions');
2026-02-19 17:37:42 +01:00
const { makeNodeStub, makeREDStub } = require('../helpers/factories');
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 = {
logger: { warn: () => {}, info: () => {}, debug: () => {}, error: () => {} },
childRegistrationUtils: { registerChild() {} },
2026-02-19 17:37:42 +01:00
updateState() {},
};
inst._commands = createRegistry(commands, { logger: inst.source.logger });
2026-02-19 17:37:42 +01:00
inst._attachInputHandler();
let doneCalled = 0;
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);
});