]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
test(charging-station): add lifecycle prototype test to validate mocking strategy
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 27 Feb 2026 01:12:00 +0000 (02:12 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 27 Feb 2026 01:12:00 +0000 (02:12 +0100)
- 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

tests/charging-station/ChargingStation.test.ts [new file with mode: 0644]

diff --git a/tests/charging-station/ChargingStation.test.ts b/tests/charging-station/ChargingStation.test.ts
new file mode 100644 (file)
index 0000000..4c82cb4
--- /dev/null
@@ -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)
+    })
+  })
+})