updates to rotating machine struct
This commit is contained in:
31
test/edge/error-paths.edge.test.js
Normal file
31
test/edge/error-paths.edge.test.js
Normal file
@@ -0,0 +1,31 @@
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user