before functional changes by codex
This commit is contained in:
0
test/edge/.gitkeep
Normal file
0
test/edge/.gitkeep
Normal file
15
test/edge/invalid-reactor-type.edge.test.js
Normal file
15
test/edge/invalid-reactor-type.edge.test.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
|
||||
const NodeClass = require('../../src/nodeClass');
|
||||
const { makeNodeStub, makeUiConfig } = require('../helpers/factories');
|
||||
|
||||
test('_setupClass with unknown reactor_type throws (known error-path behavior)', () => {
|
||||
const inst = Object.create(NodeClass.prototype);
|
||||
inst.node = makeNodeStub();
|
||||
inst.config = makeUiConfig({ reactor_type: 'UNKNOWN_TYPE' });
|
||||
|
||||
assert.throws(() => {
|
||||
inst._setupClass();
|
||||
});
|
||||
});
|
||||
30
test/edge/invalid-topic.edge.test.js
Normal file
30
test/edge/invalid-topic.edge.test.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
|
||||
const NodeClass = require('../../src/nodeClass');
|
||||
const { makeNodeStub, makeREDStub } = require('../helpers/factories');
|
||||
|
||||
test('unknown input topic does not throw and still calls done', () => {
|
||||
const inst = Object.create(NodeClass.prototype);
|
||||
const node = makeNodeStub();
|
||||
|
||||
inst.node = node;
|
||||
inst.RED = makeREDStub();
|
||||
inst.source = {
|
||||
childRegistrationUtils: {
|
||||
registerChild() {},
|
||||
},
|
||||
updateState() {},
|
||||
};
|
||||
|
||||
inst._attachInputHandler();
|
||||
|
||||
let doneCalled = 0;
|
||||
assert.doesNotThrow(() => {
|
||||
node._handlers.input({ topic: 'somethingUnknown', payload: 1 }, () => {}, () => {
|
||||
doneCalled += 1;
|
||||
});
|
||||
});
|
||||
|
||||
assert.equal(doneCalled, 1);
|
||||
});
|
||||
28
test/edge/missing-child.edge.test.js
Normal file
28
test/edge/missing-child.edge.test.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
|
||||
const NodeClass = require('../../src/nodeClass');
|
||||
const { makeNodeStub, makeREDStub } = require('../helpers/factories');
|
||||
|
||||
test('registerChild with unknown node id currently throws (known robustness gap)', () => {
|
||||
const inst = Object.create(NodeClass.prototype);
|
||||
const node = makeNodeStub();
|
||||
|
||||
inst.node = node;
|
||||
inst.RED = makeREDStub();
|
||||
inst.source = {
|
||||
childRegistrationUtils: {
|
||||
registerChild() {},
|
||||
},
|
||||
};
|
||||
|
||||
inst._attachInputHandler();
|
||||
|
||||
assert.throws(() => {
|
||||
node._handlers.input(
|
||||
{ topic: 'registerChild', payload: 'missing-child', positionVsParent: 'upstream' },
|
||||
() => {},
|
||||
() => {},
|
||||
);
|
||||
});
|
||||
});
|
||||
15
test/edge/pfr-measurement-grid.edge.test.js
Normal file
15
test/edge/pfr-measurement-grid.edge.test.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
|
||||
const { Reactor_PFR } = require('../../src/specificClass');
|
||||
const { makeReactorConfig } = require('../helpers/factories');
|
||||
|
||||
test('oxygen measurement at exact reactor length overflows PFR grid index (known bounds gap)', () => {
|
||||
const reactor = new Reactor_PFR(
|
||||
makeReactorConfig({ reactor_type: 'PFR', length: 10, resolution_L: 5, n_inlets: 1 }),
|
||||
);
|
||||
|
||||
assert.throws(() => {
|
||||
reactor._updateMeasurement('quantity (oxygen)', 2.5, 10, {});
|
||||
});
|
||||
});
|
||||
11
test/edge/structure-examples-node-type.edge.test.js
Normal file
11
test/edge/structure-examples-node-type.edge.test.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const flow = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../examples/basic.flow.json'), 'utf8'));
|
||||
|
||||
test('basic example includes node type reactor', () => {
|
||||
const count = flow.filter((n) => n && n.type === 'reactor').length;
|
||||
assert.equal(count >= 1, true);
|
||||
});
|
||||
27
test/edge/zero-dispersion.edge.test.js
Normal file
27
test/edge/zero-dispersion.edge.test.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
|
||||
const { Reactor_PFR } = require('../../src/specificClass');
|
||||
const { makeReactorConfig } = require('../helpers/factories');
|
||||
|
||||
const DAY_MS = 1000 * 60 * 60 * 24;
|
||||
|
||||
test('updateState warns when local Peclet number is too high at zero dispersion', () => {
|
||||
const reactor = new Reactor_PFR(
|
||||
makeReactorConfig({ reactor_type: 'PFR', length: 10, resolution_L: 5, volume: 50, n_inlets: 1 }),
|
||||
);
|
||||
|
||||
const warnings = [];
|
||||
reactor.logger.warn = (msg) => warnings.push(String(msg));
|
||||
|
||||
reactor.currentTime = 0;
|
||||
reactor.timeStep = 1;
|
||||
reactor.speedUpFactor = 1;
|
||||
reactor.Fs[0] = 2;
|
||||
reactor.D = 0;
|
||||
reactor.tick = () => reactor.state;
|
||||
|
||||
reactor.updateState(DAY_MS);
|
||||
|
||||
assert.equal(warnings.some((w) => w.includes('Péclet number') || w.includes('Peclet number')), true);
|
||||
});
|
||||
Reference in New Issue
Block a user