]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
test(ocpp): move mapStopReasonToOCPP20 tests to OCPP20RequestBuilders.test.ts
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 1 Apr 2026 18:04:41 +0000 (20:04 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 1 Apr 2026 18:04:41 +0000 (20:04 +0200)
Align test file structure with source: function moved to
OCPP20RequestBuilders.ts, tests follow to the 2.0/ directory.

tests/charging-station/ocpp/2.0/OCPP20RequestBuilders.test.ts [new file with mode: 0644]
tests/charging-station/ocpp/OCPPServiceUtils-pure.test.ts

diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestBuilders.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestBuilders.test.ts
new file mode 100644 (file)
index 0000000..ae61f00
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+ * @file Tests for OCPP20RequestBuilders
+ * @description Verifies OCPP 2.0 version-specific pure builders
+ *
+ * Covers:
+ * - mapStopReasonToOCPP20 — maps OCPP 1.6 stop reasons to OCPP 2.0 equivalents
+ */
+
+import assert from 'node:assert/strict'
+import { afterEach, describe, it } from 'node:test'
+
+import type { StopTransactionReason } from '../../../../src/types/index.js'
+
+import { mapStopReasonToOCPP20 } from '../../../../src/charging-station/ocpp/2.0/OCPP20RequestBuilders.js'
+import { standardCleanup } from '../../../helpers/TestLifecycleHelpers.js'
+
+await describe('OCPP20RequestBuilders', async () => {
+  afterEach(() => {
+    standardCleanup()
+  })
+
+  await describe('mapStopReasonToOCPP20', async () => {
+    await it('should map Other to Other/AbnormalCondition', () => {
+      const result = mapStopReasonToOCPP20('Other' as StopTransactionReason)
+
+      assert.strictEqual(result.stoppedReason, 'Other')
+      assert.strictEqual(result.triggerReason, 'AbnormalCondition')
+    })
+
+    await it('should map undefined to Local/StopAuthorized', () => {
+      const result = mapStopReasonToOCPP20(undefined)
+
+      assert.strictEqual(result.stoppedReason, 'Local')
+      assert.strictEqual(result.triggerReason, 'StopAuthorized')
+    })
+
+    await it('should map Remote to Remote/RemoteStop', () => {
+      const result = mapStopReasonToOCPP20('Remote' as StopTransactionReason)
+
+      assert.strictEqual(result.stoppedReason, 'Remote')
+      assert.strictEqual(result.triggerReason, 'RemoteStop')
+    })
+  })
+})
index 24688d1bc7e6f08df82a6a04695312fbe3555db8..40ba2ca72131cd84d50b07a42f01892bf5587fa1 100644 (file)
@@ -7,7 +7,6 @@
  * - buildBootNotificationRequest — builds version-specific boot notification payloads
  * - convertDateToISOString — recursively converts Date objects to ISO strings in-place
  * - isConnectorIdValid — validates connector ID ranges
- * - mapStopReasonToOCPP20 — maps OCPP 1.6 stop reasons to OCPP 2.0 equivalents (from OCPP20RequestBuilders)
  */
 
 import type { ErrorObject } from 'ajv'
@@ -17,7 +16,6 @@ import { afterEach, describe, it } from 'node:test'
 
 import type { ChargingStation } from '../../../src/charging-station/index.js'
 
-import { mapStopReasonToOCPP20 } from '../../../src/charging-station/ocpp/2.0/OCPP20RequestBuilders.js'
 import {
   ajvErrorsToErrorType,
   buildBootNotificationRequest,
@@ -31,7 +29,6 @@ import {
   IncomingRequestCommand,
   type JsonType,
   OCPPVersion,
-  type StopTransactionReason,
 } from '../../../src/types/index.js'
 import { standardCleanup } from '../../helpers/TestLifecycleHelpers.js'
 
@@ -175,29 +172,6 @@ await describe('OCPPServiceUtils — pure functions', async () => {
     })
   })
 
-  await describe('mapStopReasonToOCPP20', async () => {
-    await it('should map Other to Other/AbnormalCondition', () => {
-      const result = mapStopReasonToOCPP20('Other' as StopTransactionReason)
-
-      assert.strictEqual(result.stoppedReason, 'Other')
-      assert.strictEqual(result.triggerReason, 'AbnormalCondition')
-    })
-
-    await it('should map undefined to Local/StopAuthorized', () => {
-      const result = mapStopReasonToOCPP20(undefined)
-
-      assert.strictEqual(result.stoppedReason, 'Local')
-      assert.strictEqual(result.triggerReason, 'StopAuthorized')
-    })
-
-    await it('should map Remote to Remote/RemoteStop', () => {
-      const result = mapStopReasonToOCPP20('Remote' as StopTransactionReason)
-
-      assert.strictEqual(result.stoppedReason, 'Remote')
-      assert.strictEqual(result.triggerReason, 'RemoteStop')
-    })
-  })
-
   await describe('buildBootNotificationRequest', async () => {
     await describe('OCPP 1.6', async () => {
       await it('should build OCPP 1.6 boot notification with required fields', () => {