]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
test(ocpp): add assertion messages to assert.ok(.includes()) checks in VariableManage...
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 1 Apr 2026 18:20:37 +0000 (20:20 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 1 Apr 2026 18:20:37 +0000 (20:20 +0200)
tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts

index e1e8b2a4f4e1c2221d4c5461ffb63e72ef6f6a4f..bced6777fbfbc3a005f4cc168e5a371f7f1e2668 100644 (file)
@@ -669,7 +669,10 @@ await describe('B05 - OCPP20VariableManager', async () => {
         negRes.attributeStatusInfo.reasonCode,
         ReasonCodeEnumType.ValuePositiveOnly
       )
-      assert.ok(negRes.attributeStatusInfo.additionalInfo.includes('Positive integer > 0 required'))
+      assert.ok(
+        negRes.attributeStatusInfo.additionalInfo.includes('Positive integer > 0 required'),
+        'Expected validation error message for positive integer requirement'
+      )
       assert.strictEqual(nonIntRes.attributeStatus, SetVariableStatusEnumType.Rejected)
       if (nonIntRes.attributeStatusInfo == null) {
         assert.fail('Expected attributeStatusInfo to be defined')
@@ -678,7 +681,10 @@ await describe('B05 - OCPP20VariableManager', async () => {
         assert.fail('Expected additionalInfo to be defined')
       }
       assert.strictEqual(nonIntRes.attributeStatusInfo.reasonCode, ReasonCodeEnumType.InvalidValue)
-      assert.ok(nonIntRes.attributeStatusInfo.additionalInfo.includes('Positive integer'))
+      assert.ok(
+        nonIntRes.attributeStatusInfo.additionalInfo.includes('Positive integer'),
+        'Expected validation error message for positive integer type'
+      )
     })
 
     await it('should accept setting ConnectionUrl with valid ws URL', () => {
@@ -867,7 +873,10 @@ await describe('B05 - OCPP20VariableManager', async () => {
         negRes.attributeStatusInfo.reasonCode,
         ReasonCodeEnumType.ValuePositiveOnly
       )
-      assert.ok(negRes.attributeStatusInfo.additionalInfo.includes('Positive integer > 0 required'))
+      assert.ok(
+        negRes.attributeStatusInfo.additionalInfo.includes('Positive integer > 0 required'),
+        'Expected validation error message for positive integer requirement'
+      )
       if (nonIntRes.attributeStatusInfo == null) {
         assert.fail('Expected attributeStatusInfo to be defined')
       }
@@ -875,7 +884,10 @@ await describe('B05 - OCPP20VariableManager', async () => {
         assert.fail('Expected additionalInfo to be defined')
       }
       assert.strictEqual(nonIntRes.attributeStatusInfo.reasonCode, ReasonCodeEnumType.InvalidValue)
-      assert.ok(nonIntRes.attributeStatusInfo.additionalInfo.includes('Positive integer'))
+      assert.ok(
+        nonIntRes.attributeStatusInfo.additionalInfo.includes('Positive integer'),
+        'Expected validation error message for positive integer type'
+      )
     })
 
     await it('should accept WebSocketPingInterval zero (disable) and positive', () => {
@@ -924,7 +936,10 @@ await describe('B05 - OCPP20VariableManager', async () => {
         negRes.attributeStatusInfo.reasonCode,
         ReasonCodeEnumType.ValueZeroNotAllowed
       )
-      assert.ok(negRes.attributeStatusInfo.additionalInfo.includes('Integer >= 0 required'))
+      assert.ok(
+        negRes.attributeStatusInfo.additionalInfo.includes('Integer >= 0 required'),
+        'Expected validation error message for non-negative integer requirement'
+      )
       if (nonIntRes.attributeStatusInfo == null) {
         assert.fail('Expected attributeStatusInfo to be defined')
       }
@@ -935,7 +950,10 @@ await describe('B05 - OCPP20VariableManager', async () => {
         nonIntRes.attributeStatusInfo.reasonCode,
         ReasonCodeEnumType.ValueZeroNotAllowed
       )
-      assert.ok(nonIntRes.attributeStatusInfo.additionalInfo.includes('Integer >= 0 required'))
+      assert.ok(
+        nonIntRes.attributeStatusInfo.additionalInfo.includes('Integer >= 0 required'),
+        'Expected validation error message for non-negative integer type'
+      )
     })
 
     await it('should validate EVConnectionTimeOut positive integer >0 and reject invalid', () => {
@@ -992,7 +1010,10 @@ await describe('B05 - OCPP20VariableManager', async () => {
         negRes.attributeStatusInfo.reasonCode,
         ReasonCodeEnumType.ValuePositiveOnly
       )
-      assert.ok(negRes.attributeStatusInfo.additionalInfo.includes('Positive integer > 0 required'))
+      assert.ok(
+        negRes.attributeStatusInfo.additionalInfo.includes('Positive integer > 0 required'),
+        'Expected validation error message for positive integer requirement'
+      )
       if (nonIntRes.attributeStatusInfo == null) {
         assert.fail('Expected attributeStatusInfo to be defined')
       }
@@ -1000,7 +1021,10 @@ await describe('B05 - OCPP20VariableManager', async () => {
         assert.fail('Expected additionalInfo to be defined')
       }
       assert.strictEqual(nonIntRes.attributeStatusInfo.reasonCode, ReasonCodeEnumType.InvalidValue)
-      assert.ok(nonIntRes.attributeStatusInfo.additionalInfo.includes('Positive integer'))
+      assert.ok(
+        nonIntRes.attributeStatusInfo.additionalInfo.includes('Positive integer'),
+        'Expected validation error message for positive integer type'
+      )
     })
 
     await it('should validate MessageTimeout positive integer >0 and reject invalid', () => {
@@ -1057,7 +1081,10 @@ await describe('B05 - OCPP20VariableManager', async () => {
         negRes.attributeStatusInfo.reasonCode,
         ReasonCodeEnumType.ValuePositiveOnly
       )
-      assert.ok(negRes.attributeStatusInfo.additionalInfo.includes('Positive integer > 0 required'))
+      assert.ok(
+        negRes.attributeStatusInfo.additionalInfo.includes('Positive integer > 0 required'),
+        'Expected validation error message for positive integer requirement'
+      )
       if (nonIntRes.attributeStatusInfo == null) {
         assert.fail('Expected attributeStatusInfo to be defined')
       }
@@ -1065,7 +1092,10 @@ await describe('B05 - OCPP20VariableManager', async () => {
         assert.fail('Expected additionalInfo to be defined')
       }
       assert.strictEqual(nonIntRes.attributeStatusInfo.reasonCode, ReasonCodeEnumType.InvalidValue)
-      assert.ok(nonIntRes.attributeStatusInfo.additionalInfo.includes('Positive integer'))
+      assert.ok(
+        nonIntRes.attributeStatusInfo.additionalInfo.includes('Positive integer'),
+        'Expected validation error message for positive integer type'
+      )
     })
 
     await it('should avoid duplicate persistence operations when value unchanged', () => {