59 lines
1.5 KiB
JavaScript
59 lines
1.5 KiB
JavaScript
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
|
|
const Monster = require('../../src/specificClass');
|
|
const { makeMonsterConfig, withMockedDate } = require('../helpers/factories');
|
|
|
|
test('invalid flow bounds prevent sampling start', () => {
|
|
const monster = new Monster(
|
|
makeMonsterConfig({
|
|
constraints: {
|
|
samplingtime: 1,
|
|
minVolume: 5,
|
|
maxWeight: 23,
|
|
nominalFlowMin: 10,
|
|
flowMax: 5,
|
|
minSampleIntervalSec: 60,
|
|
},
|
|
})
|
|
);
|
|
|
|
monster.handleInput('i_start', true);
|
|
monster.sampling_program();
|
|
|
|
assert.equal(monster.invalidFlowBounds, true);
|
|
assert.equal(monster.running, false);
|
|
assert.equal(monster.i_start, false);
|
|
});
|
|
|
|
test('cooldown guard blocks pulses when flow implies oversampling', () => {
|
|
withMockedDate('2024-10-15T00:00:00Z', ({ advance }) => {
|
|
const monster = new Monster(
|
|
makeMonsterConfig({
|
|
constraints: {
|
|
samplingtime: 1,
|
|
minVolume: 5,
|
|
maxWeight: 23,
|
|
nominalFlowMin: 0,
|
|
flowMax: 6000,
|
|
maxRainRef: 10,
|
|
minSampleIntervalSec: 60,
|
|
},
|
|
})
|
|
);
|
|
|
|
monster.handleInput('input_q', { value: 200, unit: 'm3/h' });
|
|
monster.handleInput('i_start', true);
|
|
|
|
for (let i = 0; i < 80; i++) {
|
|
advance(1000);
|
|
monster.tick();
|
|
}
|
|
|
|
assert.ok(monster.sumPuls > 0);
|
|
assert.ok(monster.bucketVol > 0);
|
|
assert.ok(monster.missedSamples > 0);
|
|
assert.ok(monster.getSampleCooldownMs() > 0);
|
|
});
|
|
});
|