From: Jérôme Benoit Date: Sat, 28 Feb 2026 21:43:04 +0000 (+0100) Subject: docs(tests): update TEST_STYLE_GUIDE to reflect current utilities X-Git-Tag: ocpp-server@v3.0.0~62 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=13c6c52983f5cfa4306e8f10cd27584b7ca52775;p=e-mobility-charging-stations-simulator.git docs(tests): update TEST_STYLE_GUIDE to reflect current utilities - Remove duplicate createMockChargingStation entries - Replace waitForCondition with waitForChargingStationState - Update import examples to match current exports --- diff --git a/tests/TEST_STYLE_GUIDE.md b/tests/TEST_STYLE_GUIDE.md index 8c037187..e6e45ad0 100644 --- a/tests/TEST_STYLE_GUIDE.md +++ b/tests/TEST_STYLE_GUIDE.md @@ -254,7 +254,6 @@ const TEST_STATION_NAME = 'CS-TEST-001' // Duplicate constant Use centralized mock factories for complex objects: - `createMockChargingStation()` - From `ChargingStationTestUtils.ts` (returns `{ station, mocks }`) -- `createMockChargingStation()` - From `ChargingStationTestUtils.ts` - Auth mocks - From `tests/charging-station/ocpp/auth/helpers/MockFactories.ts` **Example:** @@ -274,14 +273,15 @@ The following utilities are available for reuse across test files: | Utility | Location | Purpose | | --------------------------------------- | ------------------------------------ | -------------------------------------------- | -| `createMockChargingStation()` | `ChargingStationTestUtils.ts` | Lightweight mock station stub | | `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 | | `MockIdTagsCache` | `mocks/MockCaches.ts` | In-memory IdTags cache mock | | `MockSharedLRUCache` | `mocks/MockCaches.ts` | In-memory LRU cache mock | -| `waitForCondition()` | `helpers/StationHelpers.ts` | Async condition waiting with timeout | +| `waitForChargingStationState()` | `helpers/StationHelpers.ts` | Async state waiting with timeout | +| `cleanupChargingStation()` | `helpers/StationHelpers.ts` | Proper station cleanup for afterEach | +| Auth factories | `ocpp/auth/helpers/MockFactories.ts` | Auth-specific mock creation | | `cleanupChargingStation()` | `helpers/StationHelpers.ts` | Proper station cleanup for afterEach | | Auth factories | `ocpp/auth/helpers/MockFactories.ts` | Auth-specific mock creation | @@ -290,7 +290,7 @@ The following utilities are available for reuse across test files: ```typescript // Good: Import shared utilities import { createMockChargingStation, cleanupChargingStation } from './ChargingStationTestUtils.js' -import { waitForCondition } from './helpers/StationHelpers.js' +import { waitForChargingStationState } from './helpers/StationHelpers.js' ``` ### Mocking Best Practices