32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
|
|
const Machine = require('../../src/specificClass');
|
|
const { makeMachineConfig, makeStateConfig } = require('../helpers/factories');
|
|
|
|
test('constructor initializes with valid curve model', () => {
|
|
const machine = new Machine(makeMachineConfig(), makeStateConfig());
|
|
assert.equal(machine.hasCurve, true);
|
|
assert.ok(machine.predictFlow);
|
|
assert.ok(machine.predictPower);
|
|
assert.ok(machine.predictCtrl);
|
|
|
|
const out = machine.getOutput();
|
|
assert.ok('state' in out);
|
|
assert.ok('mode' in out);
|
|
assert.ok('ctrl' in out);
|
|
});
|
|
|
|
test('constructor handles missing curve model without throwing', () => {
|
|
const cfg = makeMachineConfig({ asset: { supplier: 'x', category: 'machine', type: 'pump', model: 'not-existing-model', unit: 'm3/h' } });
|
|
const machine = new Machine(cfg, makeStateConfig());
|
|
|
|
assert.equal(machine.hasCurve, false);
|
|
assert.equal(machine.predictFlow, null);
|
|
assert.equal(machine.predictPower, null);
|
|
assert.equal(machine.predictCtrl, null);
|
|
|
|
const out = machine.getOutput();
|
|
assert.ok('state' in out);
|
|
});
|