From: Jérôme Benoit Date: Sat, 28 Feb 2026 18:42:13 +0000 (+0100) Subject: refactor(tests): migrate OCPP20TestUtils to createMockChargingStation X-Git-Tag: ocpp-server@v3.0.0~75 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=900dccd96c75d1ecbce83b9dc36da9092a0d251a;p=e-mobility-charging-stations-simulator.git refactor(tests): migrate OCPP20TestUtils to createMockChargingStation --- diff --git a/tests/charging-station/ocpp/2.0/OCPP20TestUtils.ts b/tests/charging-station/ocpp/2.0/OCPP20TestUtils.ts index b447bd12..79342b2f 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20TestUtils.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20TestUtils.ts @@ -18,8 +18,8 @@ import { } from '../../../../src/types/index.js' import { OCPP20IdTokenEnumType } from '../../../../src/types/ocpp/2.0/Transaction.js' import { Constants } from '../../../../src/utils/index.js' -import { createChargingStation } from '../../../ChargingStationFactory.js' import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js' +import { createMockChargingStation } from '../../ChargingStationTestUtils.js' // ============================================================================ // Testable Interfaces @@ -78,7 +78,7 @@ export interface TestableOCPP20RequestService { * @returns ChargingStation configured for OCPP 2.0 transaction testing */ export function createMockOCPP20TransactionTestStation (): ChargingStation { - return createChargingStation({ + const { station } = createMockChargingStation({ baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, @@ -92,6 +92,7 @@ export function createMockOCPP20TransactionTestStation (): ChargingStation { }, websocketPingInterval: Constants.DEFAULT_WEBSOCKET_PING_INTERVAL, }) + return station } /** @@ -117,7 +118,7 @@ export function createMockStationWithRequestTracking (): MockStationWithTracking } ) - const station = createChargingStation({ + const { station } = createMockChargingStation({ baseName: TEST_CHARGING_STATION_BASE_NAME, connectorsCount: 3, evseConfiguration: { evsesCount: 3 }, @@ -643,8 +644,11 @@ export const TransactionFlowPatterns: TransactionFlowPattern[] = [ * @returns ChargingStation with certificateManager property properly typed * @example * ```typescript - * const station = createStationWithCertificateManager( - * createChargingStation({ ocppVersion: OCPPVersion.VERSION_201 }), + * const { station } = createMockChargingStation({ + * stationInfo: { ocppVersion: OCPPVersion.VERSION_201 } + * }) + * const stationWithCerts = createStationWithCertificateManager( + * station, * createMockCertificateManager() * ) * ```