fix(BaseNodeAdapter test): close intervals to unblock batch test runs
Tests 1, 4, 5 constructed an Adapter with the default statusInterval=1000 and no mock for setInterval, leaking a real status timer that held the event loop open past the assertions. Single-file runs masked it; node --test test/basic/ blocked the whole runner. Fix: set static statusInterval = 0 + invoke node.handlers.close() (or mock setInterval where the test asserts on registration timing). 113/113 basic tests pass in batch in ~400 ms. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -79,6 +79,9 @@ test('full subclass constructs and stores wiring on this', () => {
|
|||||||
class Adapter extends BaseNodeAdapter {
|
class Adapter extends BaseNodeAdapter {
|
||||||
static DomainClass = Domain;
|
static DomainClass = Domain;
|
||||||
static commands = [];
|
static commands = [];
|
||||||
|
// Disable the real status interval — would hold the event loop open
|
||||||
|
// past the test and stall `node --test test/basic/` runs.
|
||||||
|
static statusInterval = 0;
|
||||||
buildDomainConfig() { return { extra: { foo: 1 } }; }
|
buildDomainConfig() { return { extra: { foo: 1 } }; }
|
||||||
}
|
}
|
||||||
const node = makeNode();
|
const node = makeNode();
|
||||||
@@ -88,6 +91,7 @@ test('full subclass constructs and stores wiring on this', () => {
|
|||||||
assert.equal(node.source, a.source);
|
assert.equal(node.source, a.source);
|
||||||
assert.equal(a.config.extra.foo, 1);
|
assert.equal(a.config.extra.foo, 1);
|
||||||
assert.equal(a.config.general.name, 'm1');
|
assert.equal(a.config.general.name, 'm1');
|
||||||
|
node.handlers.close(() => {});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ---- 2-4. Static-field validation -----------------------------------------
|
// ---- 2-4. Static-field validation -----------------------------------------
|
||||||
@@ -122,17 +126,20 @@ test('static commands = [] is allowed (explicit no-op registry)', () => {
|
|||||||
class Adapter extends BaseNodeAdapter {
|
class Adapter extends BaseNodeAdapter {
|
||||||
static DomainClass = makeDomain();
|
static DomainClass = makeDomain();
|
||||||
static commands = [];
|
static commands = [];
|
||||||
|
static statusInterval = 0; // see fix in test #1
|
||||||
buildDomainConfig() { return {}; }
|
buildDomainConfig() { return {}; }
|
||||||
}
|
}
|
||||||
|
const node = makeNode();
|
||||||
assert.doesNotThrow(
|
assert.doesNotThrow(
|
||||||
() => new Adapter({}, makeRED(), makeNode(), 'measurement'),
|
() => new Adapter(uiConfigFixture(), makeRED(), node, 'measurement'),
|
||||||
);
|
);
|
||||||
|
node.handlers.close(() => {});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ---- 5. Registration message after 100 ms ---------------------------------
|
// ---- 5. Registration message after 100 ms ---------------------------------
|
||||||
|
|
||||||
test('registration message fires on Port 2 after 100 ms with child.register', (t) => {
|
test('registration message fires on Port 2 after 100 ms with child.register', (t) => {
|
||||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
t.mock.timers.enable({ apis: ['setTimeout', 'setInterval'] });
|
||||||
class Adapter extends BaseNodeAdapter {
|
class Adapter extends BaseNodeAdapter {
|
||||||
static DomainClass = makeDomain();
|
static DomainClass = makeDomain();
|
||||||
static commands = [];
|
static commands = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user