From 74747d180208ae8a97dd0010e83f34f870a45a6c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 27 Feb 2026 02:12:00 +0100 Subject: [PATCH] test(charging-station): add lifecycle prototype test to validate mocking strategy - Create ChargingStation.test.ts with minimal test structure - One test: validates station instantiation and start() state transition - Uses createRealChargingStation() from test utilities - Proper cleanup with afterEach hook - BLOCKING validation passed - mocking strategy confirmed working - Fix ESLint errors: proper ChargingStation type import --- .../charging-station/ChargingStation.test.ts | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/charging-station/ChargingStation.test.ts diff --git a/tests/charging-station/ChargingStation.test.ts b/tests/charging-station/ChargingStation.test.ts new file mode 100644 index 00000000..4c82cb4b --- /dev/null +++ b/tests/charging-station/ChargingStation.test.ts @@ -0,0 +1,33 @@ +import { expect } from '@std/expect' +import { afterEach, describe, it } from 'node:test' + +import type { ChargingStation } from '../../src/charging-station/ChargingStation.js' + +import { cleanupChargingStation, createRealChargingStation } from './ChargingStationTestUtils.js' + +await describe('ChargingStation', async () => { + await describe('Lifecycle', async () => { + let station: ChargingStation | undefined + + afterEach(() => { + if (station != null) { + cleanupChargingStation(station) + } + }) + + await it('should transition from stopped to started on start()', () => { + // Arrange + const result = createRealChargingStation({ connectorsCount: 1 }) + station = result.station + + // Act + const initialStarted = station.started + station.start() + const finalStarted = station.started + + // Assert + expect(initialStarted).toBe(false) + expect(finalStarted).toBe(true) + }) + }) +}) -- 2.43.0