73 lines
1.9 KiB
JavaScript
73 lines
1.9 KiB
JavaScript
const Diffuser = require('../src/specificClass');
|
|
|
|
function makeConfig(overrides = {}) {
|
|
return {
|
|
general: {
|
|
name: 'Zone_1',
|
|
logging: {
|
|
enabled: false,
|
|
logLevel: 'error',
|
|
},
|
|
},
|
|
functionality: {
|
|
softwareType: 'diffuser',
|
|
role: 'aeration diffuser',
|
|
},
|
|
diffuser: {
|
|
number: 1,
|
|
elements: 4,
|
|
density: 2.4,
|
|
waterHeight: 4.5,
|
|
alfaFactor: 0.7,
|
|
headerPressure: 0,
|
|
localAtmPressure: 1013.25,
|
|
waterDensity: 997,
|
|
...overrides,
|
|
},
|
|
};
|
|
}
|
|
|
|
describe('diffuser specificClass', () => {
|
|
it('starts idle with zero production', () => {
|
|
const diffuser = new Diffuser(makeConfig());
|
|
|
|
expect(diffuser.idle).toBe(true);
|
|
expect(diffuser.getOutput()).toEqual(expect.objectContaining({
|
|
oKgo2H: 0,
|
|
oPLoss: expect.any(Number),
|
|
}));
|
|
});
|
|
|
|
it('calculates oxygen transfer and pressure once airflow is applied', () => {
|
|
const diffuser = new Diffuser(makeConfig());
|
|
diffuser.setFlow(24);
|
|
|
|
const output = diffuser.getOutput();
|
|
expect(diffuser.idle).toBe(false);
|
|
expect(output.oFlowElement).toBeGreaterThan(0);
|
|
expect(output.oOtr).toBeGreaterThan(0);
|
|
expect(output.oPLoss).toBeGreaterThan(diffuser.o_p_water);
|
|
expect(output.oKgo2H).toBeGreaterThan(0);
|
|
});
|
|
|
|
it('increases total pressure when water height rises', () => {
|
|
const diffuser = new Diffuser(makeConfig());
|
|
diffuser.setFlow(24);
|
|
const lowHeadLoss = diffuser.getOutput().oPLoss;
|
|
|
|
diffuser.setWaterHeight(6);
|
|
const highHeadLoss = diffuser.getOutput().oPLoss;
|
|
|
|
expect(highHeadLoss).toBeGreaterThan(lowHeadLoss);
|
|
});
|
|
|
|
it('raises warnings and alarms when flow per element is too low', () => {
|
|
const diffuser = new Diffuser(makeConfig({ elements: 1, waterHeight: 3 }));
|
|
diffuser.setFlow(0.5);
|
|
|
|
expect(diffuser.warning.state).toBe(true);
|
|
expect(diffuser.alarm.state).toBe(true);
|
|
expect(diffuser.getStatus().fill).toBe('red');
|
|
});
|
|
});
|