Refactor of reactor to use BaseNodeAdapter + commandRegistry + statusBadge. reactor follows the platform refactor plan in .claude/refactor/MODULE_SPLIT.md. Tests stay green; CONTRACT.md generated; legacy aliases preserved. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
|
|
const NodeClass = require('../../src/nodeClass');
|
|
const { makeNodeStub } = require('../helpers/factories');
|
|
|
|
// Post-refactor: BaseNodeAdapter handles registration via _scheduleRegistration
|
|
// (was _registerChild). Topic moved from 'registerChild' to 'child.register'.
|
|
test('_scheduleRegistration emits delayed child.register message on output 2', () => {
|
|
const inst = Object.create(NodeClass.prototype);
|
|
const node = makeNodeStub();
|
|
|
|
inst.node = node;
|
|
inst.config = { functionality: { positionVsParent: 'downstream', distance: null } };
|
|
|
|
const originalSetTimeout = global.setTimeout;
|
|
const delays = [];
|
|
global.setTimeout = (fn, ms) => { delays.push(ms); fn(); return 1; };
|
|
|
|
try {
|
|
inst._scheduleRegistration();
|
|
} finally {
|
|
global.setTimeout = originalSetTimeout;
|
|
}
|
|
|
|
assert.deepEqual(delays, [100]);
|
|
assert.equal(node._sent.length, 1);
|
|
assert.equal(Array.isArray(node._sent[0]), true);
|
|
assert.equal(node._sent[0][2].topic, 'child.register');
|
|
assert.equal(node._sent[0][2].payload, node.id);
|
|
assert.equal(node._sent[0][2].positionVsParent, 'downstream');
|
|
});
|