Skip to content
Snippets Groups Projects
Commit 82b49f6d authored by François Grand's avatar François Grand
Browse files

fix(test): message "describe with no children"

rules:
- there can be nested describe()s
- there can be code between a describe() and its direct describe() child
- there can be multiple it()s in a describe()
- there cannot be code between a describe() and its direct it() children

refs #318
parent f10ec4db
No related branches found
No related tags found
No related merge requests found
......@@ -80,39 +80,43 @@ export function testStructure(
}
}
function testStructureLoopPrm(
st: Structure,
bNotZDV: boolean,
prm: ParamDefinition) {
function testStructureLoopPrm(st: Structure, bNotZDV: boolean, prm: ParamDefinition) {
describe(`Calc(${prm.symbol})`, () => {
beforeAll(() => {
st.calculatedParam = prm;
});
if ([ParamCalculability.DICHO, ParamCalculability.EQUATION].includes(prm.calculability)) {
if (prm.symbol === "W" && prm.currentValue === Infinity) {
// Le calcul de l'ouverture sur les seuils doit renvoyer une exception (cas impossible)
it(`should return exception`, () => {
it(`should return exception`, () => {
// Le calcul de l'ouverture sur les seuils doit renvoyer une exception (cas impossible)
if ([ParamCalculability.DICHO, ParamCalculability.EQUATION].includes(prm.calculability)) {
if (prm.symbol === "W" && prm.currentValue === Infinity) {
expect(
() => { st.CalcSerie(); }
).toThrow(new Error("Structure:Calc : Calcul de W impossible sur un seuil"));
});
} else {
if (bNotZDV) {
// Les lois CEM88D et CUNGE80 ne font pas intervenir ZDV dans le calcul d'un orifice noyé
it(`should return an error`, () => {
}
}
});
it(`should return an error`, () => {
// Les lois CEM88D et CUNGE80 ne font pas intervenir ZDV dans le calcul d'un orifice noyé
if ([ParamCalculability.DICHO, ParamCalculability.EQUATION].includes(prm.calculability)) {
if (!(prm.symbol === "W" && prm.currentValue === Infinity)) {
if (bNotZDV) {
expect(
st.CalcSerie().log.messages[0].code
).toBe(MessageCode.ERROR_STRUCTURE_ZDV_PAS_CALCULABLE);
});
} else {
it(`should return prm.currentValue`, () => {
}
}
}
});
it(`should return prm.currentValue`, () => {
if ([ParamCalculability.DICHO, ParamCalculability.EQUATION].includes(prm.calculability)) {
if (!(prm.symbol === "W" && prm.currentValue === Infinity)) {
if (!bNotZDV) {
checkResult(st.CalcSerie(prm.domain.getBoundedValue(prm.singleValue + 100)), prm.currentValue);
});
}
}
}
}
});
});
}
/**
......@@ -148,15 +152,15 @@ export function testParallelStructures(o: { ps: ParallelStructure, ld: number[]
if (prm.visible) {
describe(`Calc(${prm.symbol})`, () => {
const ref: number = prm.currentValue;
beforeAll( () => {
beforeAll(() => {
o.ps.calculatedParam = prm;
});
beforeEach(() => {
originalCalculatedValue = o.ps.calculatedParam.currentValue;
if ( // #136 Multiple solutions for GateCem88v ZDV
! (o.ps.calculatedParam.parentNub.properties
!(o.ps.calculatedParam.parentNub.properties
.getPropValue("loiDebit") === LoiDebit.GateCem88v
&& o.ps.calculatedParam.symbol === "ZDV")
&& o.ps.calculatedParam.symbol === "ZDV")
) {
// altering value to force looking for the solution
o.ps.calculatedParam.singleValue = Math.min(
......@@ -169,41 +173,51 @@ export function testParallelStructures(o: { ps: ParallelStructure, ld: number[]
afterEach(() => {
o.ps.calculatedParam.singleValue = originalCalculatedValue;
});
if (prm.symbol === "W" && prm.currentValue === Infinity) {
it(`should return exception`, () => {
// Le calcul de l'ouverture sur les seuils doit renvoyer une exception (cas impossible)
it(`should return exception`, () => {
if (prm.symbol === "W" && prm.currentValue === Infinity) {
expect(
() => { o.ps.CalcSerie(); }
).toThrow(new Error("Structure:Calc : Calcul de W impossible sur un seuil"));
});
} else if (prm.symbol === "ZDV" && !o.ps.structures[i].isZDVcalculable) {
}
});
it(`should return an error`, () => {
// Les lois GateCEM88D et CUNGE80 ne permettent pas le calcul de ZDV
it(`should return an error`, () => {
expect(
o.ps.CalcSerie().log.messages[0].code
).toBe(MessageCode.ERROR_STRUCTURE_ZDV_PAS_CALCULABLE);
});
} else if (
o.ld[i] === LoiDebit.TriangularWeirFree &&
prm.symbol === "alpha2"
) {
if (!(prm.symbol === "W" && prm.currentValue === Infinity)) {
if (prm.symbol === "ZDV" && !o.ps.structures[i].isZDVcalculable) {
expect(
o.ps.CalcSerie().log.messages[0].code
).toBe(MessageCode.ERROR_STRUCTURE_ZDV_PAS_CALCULABLE);
}
}
});
it(`should return ${ref}`, () => {
// Le calcul de l'angle de l'équation triangulaire n'est pas assez précis
it(`should return ${ref}`, () => {
checkResult(o.ps.CalcSerie(), ref, 1);
});
} else {
if (!(prm.symbol === "W" && prm.currentValue === Infinity)) {
if (!(prm.symbol === "ZDV" && !o.ps.structures[i].isZDVcalculable)) {
if (o.ld[i] === LoiDebit.TriangularWeirFree && prm.symbol === "alpha2") {
checkResult(o.ps.CalcSerie(), ref, 1);
}
}
}
});
it(`should return ${ref}`, () => {
// Cas normal : On teste la valeur calculée
if (ParamCalculability.DICHO === prm.calculability) {
it(`should return ${ref}`, () => {
// console.log(o.ps.serialise());
checkResult(o.ps.CalcSerie(), ref);
/* checkResult(o.ps.Calc({
uid: o.ps.structures[i].uid,
symbol: prm.symbol
}), ref); */
});
if (!(prm.symbol === "W" && prm.currentValue === Infinity)) {
if (!(prm.symbol === "ZDV" && !o.ps.structures[i].isZDVcalculable)) {
if (!(o.ld[i] === LoiDebit.TriangularWeirFree && prm.symbol === "alpha2")) {
if (ParamCalculability.DICHO === prm.calculability) {
// console.log(o.ps.serialise());
checkResult(o.ps.CalcSerie(), ref);
/* checkResult(o.ps.Calc({
uid: o.ps.structures[i].uid,
symbol: prm.symbol
}), ref); */
}
}
}
}
}
});
});
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment