]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor(tests): migrate inline mock stations to shared factory
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 2 Apr 2026 20:49:24 +0000 (22:49 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 2 Apr 2026 20:49:24 +0000 (22:49 +0200)
Replace inline as-unknown-as ChargingStation casts in
CertificateAuthStrategy and OCPP20AuthAdapter tests with
createMockAuthServiceTestStation factory. Add inAcceptedState
method to the shared auth test station factory.

tests/charging-station/ocpp/auth/helpers/MockFactories.ts
tests/charging-station/ocpp/auth/strategies/CertificateAuthStrategy.test.ts

index b2186cbeec82e89147e7d36939d66ac859410f7b..f1ca5865a81671a175033984762f5ec9465713ad 100644 (file)
@@ -297,6 +297,7 @@ export const createMockAuthServiceTestStation = (
   ({
     getConnectorStatus: () => ({ status: 'Available' }),
     idTagLocalAuthorized: () => false,
+    inAcceptedState: () => true,
     isConnected: () => true,
     logPrefix: () => `[TEST-CS-${id}]`,
     sendRequest: () =>
index 31597349eefd8813f54aec4ef4a2d4da989ec392..5fe4c621391d59ae9cba755c2cbcd548b4848270 100644 (file)
@@ -20,6 +20,7 @@ import { standardCleanup } from '../../../../helpers/TestLifecycleHelpers.js'
 import {
   createMockAuthorizationResult,
   createMockAuthRequest,
+  createMockAuthServiceTestStation,
   createMockOCPPAdapter,
   createTestAuthConfig,
 } from '../helpers/MockFactories.js'
@@ -30,13 +31,7 @@ await describe('CertificateAuthStrategy', async () => {
   let mockOCPP20Adapter: OCPPAuthAdapter
 
   beforeEach(() => {
-    mockStation = {
-      logPrefix: () => '[TEST-CS-001]',
-      stationInfo: {
-        chargingStationId: 'TEST-CS-001',
-        ocppVersion: OCPPVersion.VERSION_201,
-      },
-    } as unknown as ChargingStation
+    mockStation = createMockAuthServiceTestStation('001', OCPPVersion.VERSION_201)
 
     mockOCPP20Adapter = createMockOCPPAdapter(OCPPVersion.VERSION_201, {
       authorizeRemote: () =>