before functional changes by codex
This commit is contained in:
55
test/basic/constructor.basic.test.js
Normal file
55
test/basic/constructor.basic.test.js
Normal file
@@ -0,0 +1,55 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
|
||||
const NodeClass = require('../../src/nodeClass');
|
||||
const { Reactor_CSTR, Reactor_PFR } = require('../../src/specificClass');
|
||||
const { makeUiConfig, makeReactorConfig, makeNodeStub } = require('../helpers/factories');
|
||||
|
||||
test('_loadConfig coerces numeric fields and builds initial state vector', () => {
|
||||
const inst = Object.create(NodeClass.prototype);
|
||||
inst.node = { id: 'n-reactor-1' };
|
||||
inst.name = 'reactor';
|
||||
|
||||
inst._loadConfig(
|
||||
makeUiConfig({
|
||||
volume: '12.5',
|
||||
length: '9',
|
||||
resolution_L: '7',
|
||||
alpha: '0.5',
|
||||
n_inlets: '3',
|
||||
timeStep: '2',
|
||||
S_O_init: '1.1',
|
||||
}),
|
||||
);
|
||||
|
||||
assert.equal(inst.config.volume, 12.5);
|
||||
assert.equal(inst.config.length, 9);
|
||||
assert.equal(inst.config.resolution_L, 7);
|
||||
assert.equal(inst.config.alpha, 0.5);
|
||||
assert.equal(inst.config.n_inlets, 3);
|
||||
assert.equal(inst.config.timeStep, 2);
|
||||
assert.equal(inst.config.initialState.length, 13);
|
||||
assert.equal(inst.config.initialState[0], 1.1);
|
||||
});
|
||||
|
||||
test('_setupClass selects Reactor_CSTR when configured as CSTR', () => {
|
||||
const inst = Object.create(NodeClass.prototype);
|
||||
inst.node = makeNodeStub();
|
||||
inst.config = makeReactorConfig({ reactor_type: 'CSTR' });
|
||||
|
||||
inst._setupClass();
|
||||
|
||||
assert.ok(inst.source instanceof Reactor_CSTR);
|
||||
assert.equal(inst.node.source, inst.source);
|
||||
});
|
||||
|
||||
test('_setupClass selects Reactor_PFR when configured as PFR', () => {
|
||||
const inst = Object.create(NodeClass.prototype);
|
||||
inst.node = makeNodeStub();
|
||||
inst.config = makeReactorConfig({ reactor_type: 'PFR', length: 10, resolution_L: 5 });
|
||||
|
||||
inst._setupClass();
|
||||
|
||||
assert.ok(inst.source instanceof Reactor_PFR);
|
||||
assert.equal(inst.node.source, inst.source);
|
||||
});
|
||||
Reference in New Issue
Block a user