From fb0cfd4e4578f3dab378d58d0d86abfae2349fbf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr>
Date: Thu, 23 Mar 2023 13:26:12 +0100
Subject: [PATCH] test: add submergence check for WeirSubmerged discharge law

refs #302
---
 spec/structure/structure_weir_submerged.spec.ts      |  7 +++----
 .../structure_weir_submerged_larinier.spec.ts        | 12 ++++++++++++
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/spec/structure/structure_weir_submerged.spec.ts b/spec/structure/structure_weir_submerged.spec.ts
index e86a30e7..2f401d3c 100644
--- a/spec/structure/structure_weir_submerged.spec.ts
+++ b/spec/structure/structure_weir_submerged.spec.ts
@@ -35,10 +35,9 @@ describe("Class StructureWeirSubmerged: ", () => {
             structTest.prms.Z2.singleValue = 105;
             structTest.prms.ZDV.singleValue = 100;
             const res = structTest.CalcSerie().resultElement;
-            expect(res.log.messages.length).toBe(1);
-            expect(
-                res.log.messages[0].code
-            ).toBe(MessageCode.WARNING_WEIR_SUBMERGENCE_LOWER_THAN_08);
+            expect(res.log.messages.length).toBe(2);
+            const ok = res.log.messages[0].code === MessageCode.WARNING_WEIR_SUBMERGENCE_LOWER_THAN_08 || res.log.messages[1].code === MessageCode.WARNING_WEIR_SUBMERGENCE_LOWER_THAN_08;
+            expect(ok).toBe(true);
         });
     });
 });
diff --git a/spec/structure/structure_weir_submerged_larinier.spec.ts b/spec/structure/structure_weir_submerged_larinier.spec.ts
index 40c0e168..ba486d4c 100644
--- a/spec/structure/structure_weir_submerged_larinier.spec.ts
+++ b/spec/structure/structure_weir_submerged_larinier.spec.ts
@@ -54,4 +54,16 @@ describe("Class StructureWeirSubmergedLarinier: ", () => {
             ).toBe(MessageCode.WARNING_SLOT_SUBMERGENCE_NOT_BETWEEN_07_AND_09);
         });
     });
+    describe("Calcul avec h2/h1 < 0.5 (=0.4) : ", () => {
+        it("le log devrait contenir au moins un message d'erreur", () => {
+            const structTest = getStructTest();
+            structTest.prms.Z1.singleValue = 110;
+            structTest.prms.Z2.singleValue = 104;
+            structTest.prms.ZDV.singleValue = 100;
+            const res = structTest.CalcSerie().resultElement;
+            expect(res.log.messages.length).toBe(2);
+            const ok = res.log.messages[0].code === MessageCode.ERROR_STRUCTURE_SUBMERGENCE_LOWER_THAN || res.log.messages[1].code === MessageCode.ERROR_STRUCTURE_SUBMERGENCE_LOWER_THAN;
+            expect(ok).toBe(true);
+        });
+    });
 });
-- 
GitLab