Aligns OCPP 2.0 ResponseService test wiring with the established pattern used
by RequestService and VariableManager:
- New src/charging-station/ocpp/2.0/__testable__/OCPP20ResponseServiceTestable.ts
exporting createTestableResponseService + TestableOCPP20ResponseService;
mirrors OCPP20RequestServiceTestable.ts structure (function declarations,
file-level JSDoc with @example, double-cast through unknown).
- __testable__/index.ts re-exports the new module.
- OCPP20ResponseService-TransactionEvent.test.ts and -ForceTxOnInvalid.test.ts
now import createTestableResponseService from __testable__/index.js;
call sites renamed (drops redundant OCPP20 prefix, consistent with
createTestableRequestService).
- OCPP20ResponseServiceTestUtils.ts now contains only the test-only
buildTransactionEventRequest payload builder; adopts @file header and
arrow-style export to harmonize with MockFactories.ts neighbour.
Test-only refactor; no production behavior change.
Centralizes the two patterns used by OCPP 2.0 IncomingRequest tests to
inject mock OCPPAuthService instances into the factory cache:
- injectMockAuthService(station, service) — wraps the station-id lookup +
OCPPAuthServiceFactory.setInstanceForTesting plumbing; replaces the
duplicated boilerplate in ClearCache.test.ts and LocalAuthList.test.ts.
- withThrowingAuthServiceFactory(errorMessage, fn) — scoped monkey-patch +
try/finally restore for the 3 sites that must exercise a failing
getInstance (factory unavailable, no Authorization Cache support).
Required because setInstanceForTesting only injects a returned instance;
it cannot make getInstance itself throw.
Side effect of the helper adoption:
- LocalAuthList.test.ts drops the suite-scoped originalGetInstance save
and afterEach restore — no longer needed since every monkey-patch is
now scoped to its own test via withThrowingAuthServiceFactory.
- ClearCache.test.ts drops the local try/finally on the no-cache-support
test for the same reason.
Test-only refactor; no production behavior change.
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
* test(ocpp): align auth mock helper verbs and drop dead return type
V2-1: harmonize JSDoc verbs across the auth injection helpers — `inject*`
docstrings now start with 'Inject' to match the function name, and the local
`setupMockAuthService` wrappers (which build the mock + inject it) now start
with 'Configure and inject' to reflect their broader role. Avoids the verb
collision between the shared `injectMockAuthService` and the local
`setupMockAuthService` helpers.
V2-2: drop the dead `OCPPAuthService` return type from LocalAuthList's local
`setupMockAuthService` — no call site captured the return value. Also drops
the now-unused `OCPPAuthService` type import.
Test-only refactor; no production behavior change.
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
* test(ocpp): align ClearCache test hook ordering with siblings
Moves the `afterEach` block below `beforeEach` in ClearCache.test.ts to match
the before-then-after ordering used by LocalAuthList, TransactionEvent and
ForceTxOnInvalid test files. Cosmetic; no behavior change.