28 lines
922 B
JavaScript
28 lines
922 B
JavaScript
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
|
|
const Machine = require('../../src/specificClass');
|
|
const { makeMachineConfig, makeStateConfig, makeChildMeasurement } = require('../helpers/factories');
|
|
|
|
test('registerChild listens to measurement events and stores measured pressure', async () => {
|
|
const machine = new Machine(makeMachineConfig(), makeStateConfig());
|
|
const child = makeChildMeasurement({ positionVsParent: 'downstream', type: 'pressure', unit: 'mbar' });
|
|
|
|
machine.registerChild(child, 'measurement');
|
|
|
|
child.measurements
|
|
.type('pressure')
|
|
.variant('measured')
|
|
.position('downstream')
|
|
.value(123, Date.now(), 'mbar');
|
|
|
|
const stored = machine.measurements
|
|
.type('pressure')
|
|
.variant('measured')
|
|
.position('downstream')
|
|
.getCurrentValue('mbar');
|
|
|
|
assert.equal(typeof stored, 'number');
|
|
assert.equal(Math.round(stored), 123);
|
|
});
|