before functional changes by codex

This commit is contained in:
znetsixe
2026-02-19 17:37:09 +01:00
parent 6b58dd4bd5
commit 00858eb853
20 changed files with 1982 additions and 3 deletions

0
test/edge/.gitkeep Normal file
View File

View File

@@ -0,0 +1,58 @@
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);
});
});

View File

@@ -0,0 +1,21 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const dir = path.resolve(__dirname, '../../examples');
const exampleFlows = [
'basic.flow.json',
'integration.flow.json',
'edge.flow.json',
'monster-dashboard.flow.json',
'monster-api-dashboard.flow.json'
];
test('all example flows include node type monster', () => {
for (const file of exampleFlows) {
const flow = JSON.parse(fs.readFileSync(path.join(dir, file), 'utf8'));
const count = flow.filter((n) => n && n.type === 'monster').length;
assert.equal(count >= 1, true, file + ' missing monster node');
}
});