From a6a46a4fbb3ee695bf7dd029a0af64a5f7885ba7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 28 Feb 2026 21:04:10 +0100 Subject: [PATCH] docs(tests): update TEST_STYLE_GUIDE to reference new factory - Updated TEST_STYLE_GUIDE.md to use createMockChargingStation - Fixed comment in ChargingStationTestUtils.ts - Removed references to deleted ChargingStationFactory.ts Final cleanup complete --- tests/TEST_STYLE_GUIDE.md | 8 ++++---- tests/charging-station/ChargingStationTestUtils.ts | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/TEST_STYLE_GUIDE.md b/tests/TEST_STYLE_GUIDE.md index 886c407b..8c037187 100644 --- a/tests/TEST_STYLE_GUIDE.md +++ b/tests/TEST_STYLE_GUIDE.md @@ -253,16 +253,16 @@ const TEST_STATION_NAME = 'CS-TEST-001' // Duplicate constant Use centralized mock factories for complex objects: -- `createChargingStation()` - From `ChargingStationFactory.ts` +- `createMockChargingStation()` - From `ChargingStationTestUtils.ts` (returns `{ station, mocks }`) - `createMockChargingStation()` - From `ChargingStationTestUtils.ts` - Auth mocks - From `tests/charging-station/ocpp/auth/helpers/MockFactories.ts` **Example:** ```typescript -import { createChargingStation } from '../ChargingStationFactory.js' +import { createMockChargingStation } from './ChargingStationTestUtils.js' -const station = await createChargingStation({ +const { station } = createMockChargingStation({ ocppVersion: OCPPVersion.VERSION_20, numberOfConnectors: 2, }) @@ -275,7 +275,7 @@ The following utilities are available for reuse across test files: | Utility | Location | Purpose | | --------------------------------------- | ------------------------------------ | -------------------------------------------- | | `createMockChargingStation()` | `ChargingStationTestUtils.ts` | Lightweight mock station stub | -| `createChargingStation()` | `ChargingStationFactory.ts` | Full test station with OCPP services | +| `createMockChargingStation()` | `ChargingStationTestUtils.ts` | Full test station with OCPP services + mocks | | `createConnectorStatus()` | `helpers/StationHelpers.ts` | ConnectorStatus factory with defaults | | `createStationWithCertificateManager()` | `ocpp/2.0/OCPP20TestUtils.ts` | Station with certificate manager (type-safe) | | `MockWebSocket` | `mocks/MockWebSocket.ts` | WebSocket simulation with message capture | diff --git a/tests/charging-station/ChargingStationTestUtils.ts b/tests/charging-station/ChargingStationTestUtils.ts index 7c536b71..4d27ced1 100644 --- a/tests/charging-station/ChargingStationTestUtils.ts +++ b/tests/charging-station/ChargingStationTestUtils.ts @@ -8,7 +8,7 @@ * - MockWebSocket: Captures sent messages for assertion * - Singleton mocking: Overrides getInstance() for shared caches * - Cleanup utilities: Prevents test pollution via timer/listener cleanup - * @see tests/ChargingStationFactory.ts for mock factory (creates mock objects) + * @see tests/charging-station/helpers/StationHelpers.ts for mock factory implementation * @see tests/charging-station/ChargingStationTestConstants.ts for test constants */ @@ -38,7 +38,6 @@ export { waitForCondition, } from './helpers/StationHelpers.js' - export { MockIdTagsCache, MockSharedLRUCache } from './mocks/MockCaches.js' // Re-export all mock classes export { MockWebSocket, WebSocketReadyState } from './mocks/MockWebSocket.js' -- 2.43.0