32 lines
1001 B
JavaScript
32 lines
1001 B
JavaScript
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
|
|
const Machine = require('../../src/specificClass');
|
|
const NodeClass = require('../../src/nodeClass');
|
|
const { makeMachineConfig, makeStateConfig, makeNodeStub } = require('../helpers/factories');
|
|
|
|
test('setpoint rejects negative inputs without throwing', async () => {
|
|
const machine = new Machine(makeMachineConfig(), makeStateConfig({ state: { current: 'operational' } }));
|
|
await assert.doesNotReject(async () => {
|
|
await machine.setpoint(-1);
|
|
});
|
|
});
|
|
|
|
test('nodeClass _updateNodeStatus returns error status on internal failure', () => {
|
|
const inst = Object.create(NodeClass.prototype);
|
|
const node = makeNodeStub();
|
|
inst.node = node;
|
|
inst.source = {
|
|
currentMode: 'auto',
|
|
state: {
|
|
getCurrentState() {
|
|
throw new Error('boom');
|
|
},
|
|
},
|
|
};
|
|
|
|
const status = inst._updateNodeStatus();
|
|
assert.equal(status.text, 'Status Error');
|
|
assert.equal(node._errors.length, 1);
|
|
});
|