Commit f0898ee9 authored by Mathias Chouet's avatar Mathias Chouet :spaghetti:
Browse files

Update jasmine tests

Showing with 26 additions and 1 deletion
+26 -1
......@@ -25,4 +25,16 @@ describe("Class PabChute: ", () => {
pabChuteTest("Z2", 0.5);
pabChuteTest("DH", 1.5);
it ("Z1 < Z2 should lead to log error entry", () => {
const prms = new PabChuteParams(
100, // Cote amont Z1
100.5, // Cote aval Z2
1.5, // Chute DH
);
const nub = new PabChute(prms);
expect(nub.Calc("DH", 0).log.messages.length).toBeGreaterThan(0);
});
});
......@@ -53,7 +53,7 @@ describe("Class PabNombre: ", () => {
expect(nub.result.getExtraResult("DHR")).toBe(0);
});
it ("non-integer number of basins should throw an error", () => {
it ("non-integer number of basins should lead to log error entry", () => {
const prms = new PabNombreParams(
3, // Chute totale DHT
4.5, // Nombre de bassins N
......
......@@ -3,6 +3,7 @@ import { Nub } from "../nub";
import { ParamCalculability, ParamDefinition, ParamFamily } from "../param/param-definition";
import { ParamDomainValue } from "../param/param-domain";
import { ParamsEquation } from "../param/params-equation";
import { Message, MessageCode } from "../util/message";
import { Result } from "../util/result";
export class PabChuteParams extends ParamsEquation {
......@@ -60,6 +61,13 @@ export class PabChute extends Nub {
public Equation(sVarCalc: string): Result {
let v: number;
if (! [ "Z1", "Z2" ].includes(sVarCalc) && this.prms.Z1.singleValue <= this.prms.Z2.singleValue) {
const m = new Message(MessageCode.ERROR_ELEVATION_ZI_LOWER_THAN_Z2);
m.extraVar.Z1 = this.prms.Z1.singleValue;
m.extraVar.Z2 = this.prms.Z2.singleValue;
return new Result(m);
}
switch (sVarCalc) {
case "Z1":
v = this.prms.Z2.v + this.prms.DH.v;
......
......@@ -43,6 +43,11 @@ export enum MessageCode {
*/
ERROR_DICHO_FUNCTION_VARIATION,
/**
* la cote amont Z1 est plus basse que la cote aval Z2
*/
ERROR_ELEVATION_ZI_LOWER_THAN_Z2,
/**
* les bornes de l'intervalle d'un ParamDomain sont incorrectes
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment