]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix(tests): resolve all ESLint errors in factory consolidation
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 28 Feb 2026 20:46:29 +0000 (21:46 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 28 Feb 2026 20:46:29 +0000 (21:46 +0100)
- Fix incorrect import paths (../../../ -> ../../ChargingStationTestUtils.js)
- Replace remaining createChargingStation() calls with createMockChargingStation()
- Remove obsolete TestChargingStation type references
- Remove unused variables and duplicate declarations
- Update type annotations for mock stations

All 291 tests pass, 0 ESLint errors.

21 files changed:
tests/charging-station/Helpers.test.ts
tests/charging-station/helpers/StationHelpers.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CertificateSigned.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DeleteCertificate.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetInstalledCertificateIds.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetVariables.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-InstallCertificate.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStartTransaction.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStopTransaction.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-Reset.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-SetVariables.test.ts
tests/charging-station/ocpp/2.0/OCPP20RequestService-BootNotification.test.ts
tests/charging-station/ocpp/2.0/OCPP20RequestService-HeartBeat.test.ts
tests/charging-station/ocpp/2.0/OCPP20RequestService-ISO15118.test.ts
tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts
tests/charging-station/ocpp/2.0/OCPP20RequestService-SignCertificate.test.ts
tests/charging-station/ocpp/2.0/OCPP20RequestService-StatusNotification.test.ts
tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts
tests/charging-station/ocpp/auth/factories/AuthComponentFactory.test.ts

index 3ae8df8afe95476bb956fdb7abf715f19a3e75d4..afbed311c539c5fd91260f8392a699de9c9032b2 100644 (file)
@@ -33,8 +33,8 @@ import {
   type Reservation,
 } from '../../src/types/index.js'
 import { logger } from '../../src/utils/Logger.js'
-import { createMockChargingStation, createMockChargingStationTemplate } from './ChargingStationTestUtils.js'
 import { standardCleanup } from '../helpers/TestLifecycleHelpers.js'
+import { createMockChargingStation, createMockChargingStationTemplate } from './ChargingStationTestUtils.js'
 
 await describe('Helpers test suite', async () => {
   const baseName = 'CS-TEST'
index 070a8c15ee05c7b89bb4c04e31456be53b939a80..2e61b339950e710771de0f96e9769ff35fc3ef66 100644 (file)
@@ -854,12 +854,27 @@ export function createMockChargingStation (
     webSocket: mockWebSocket,
   }
 
+  const typedStation: ChargingStation = station as unknown as ChargingStation
+
   return {
     mocks,
-    station: station as unknown as ChargingStation,
+    station: typedStation,
   }
 }
 
+/**
+ * Create a mock charging station template for testing
+ * @param baseName - Base name for the template
+ * @returns ChargingStationTemplate with minimal required properties for testing
+ */
+export function createMockChargingStationTemplate (
+  baseName: string = TEST_CHARGING_STATION_BASE_NAME
+): ChargingStationTemplate {
+  return {
+    baseName,
+  } as ChargingStationTemplate
+}
+
 /**
  * Reset a ChargingStation to its initial state
  *
@@ -975,16 +990,3 @@ function resetConnectorStatus (status: ConnectorStatus, isConnectorZero: boolean
     status.transactionSetInterval = undefined
   }
 }
-
-/**
- * Create a mock charging station template for testing
- * @param baseName - Base name for the template
- * @returns ChargingStationTemplate with minimal required properties for testing
- */
-export function createMockChargingStationTemplate (
-  baseName: string = TEST_CHARGING_STATION_BASE_NAME
-): ChargingStationTemplate {
-  return {
-    baseName,
-  } as ChargingStationTemplate
-}
index 18b3e74ac293ec61df58366e5bc633ce18883bb2..ded401fa6116e6c38e5705feecb31532fb76789f 100644 (file)
@@ -24,8 +24,8 @@ import {
   OCPPVersion,
 } from '../../../../src/types/index.js'
 import { Constants } from '../../../../src/utils/index.js'
-import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js'
+import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 
 const VALID_PEM_CERTIFICATE = `-----BEGIN CERTIFICATE-----
 MIIBkTCB+wIJAKHBfpvPA0GXMA0GCSqGSIb3DQEBCwUAMBExDzANBgNVBAMMBnRl
@@ -74,15 +74,6 @@ interface MockCertificateManager extends OCPP20CertificateManagerInterface {
   validateCertificateFormat: Mock<(cert: string) => boolean>
 }
 
-/**
- * Test-specific ChargingStation interface with certificate management
- * Extends ChargingStation with properties needed for certificate tests
- */
-interface TestableChargingStationWithCertificate extends ChargingStation {
-  certificateManager?: MockCertificateManager
-  closeWSConnection?: Mock<() => void>
-}
-
 const createMockCertificateManager = (
   options: {
     storeCertificateError?: Error
index 8dab1628e94e1316c01f2f5031411314ec95027b..54256f88c2443674ef47786ea937ad59f9b36fc1 100644 (file)
@@ -6,13 +6,15 @@
 import { expect } from '@std/expect'
 import { afterEach, beforeEach, describe, it, mock } from 'node:test'
 
+import type { ChargingStation } from '../../../../src/charging-station/index.js'
+
 import { createTestableIncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/__testable__/index.js'
 import { OCPP20IncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.js'
 import { OCPPAuthServiceFactory } from '../../../../src/charging-station/ocpp/auth/services/OCPPAuthServiceFactory.js'
 import { GenericStatus, OCPPVersion } from '../../../../src/types/index.js'
 import { Constants } from '../../../../src/utils/index.js'
-import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js'
+import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 
 await describe('C11 - Clear Authorization Data in Authorization Cache', async () => {
   afterEach(() => {
@@ -96,9 +98,7 @@ await describe('C11 - Clear Authorization Data in Authorization Cache', async ()
     await it('should NOT call idTagsCache.deleteIdTags() on ClearCache request', async () => {
       // Verify that IdTagsCache is not touched
       let deleteIdTagsCalled = false
-      const originalDeleteIdTags = station.idTagsCache.deleteIdTags.bind(
-        station.idTagsCache
-      )
+      const originalDeleteIdTags = station.idTagsCache.deleteIdTags.bind(station.idTagsCache)
 
       Object.assign(station.idTagsCache, {
         deleteIdTags: () => {
index a8c64efdb8bb692b2ab7c44a2a2e58f33b34156d..28ca9d66f216eeef341f8a514b2a31a5856631a6 100644 (file)
@@ -6,6 +6,7 @@
 import { expect } from '@std/expect'
 import { afterEach, beforeEach, describe, it, mock } from 'node:test'
 
+import type { ChargingStation } from '../../../../src/charging-station/index.js'
 import type { ChargingStationWithCertificateManager } from '../../../../src/charging-station/ocpp/2.0/OCPP20CertificateManager.js'
 
 import { createTestableIncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/__testable__/index.js'
@@ -19,8 +20,8 @@ import {
   ReasonCodeEnumType,
 } from '../../../../src/types/index.js'
 import { Constants } from '../../../../src/utils/index.js'
-import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js'
+import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import { createStationWithCertificateManager } from './OCPP20TestUtils.js'
 
 const VALID_CERTIFICATE_HASH_DATA = {
index e5f672386ab1cf4ea2af5b5d24c75915b41936d4..d287f53a31dc4a16ef4cf40ff78a83f9b721d4ed 100644 (file)
@@ -5,6 +5,8 @@
 import { expect } from '@std/expect'
 import { afterEach, beforeEach, describe, it } from 'node:test'
 
+import type { ChargingStation } from '../../../../src/charging-station/index.js'
+
 import {
   addConfigurationKey,
   setConfigurationKeyValue,
@@ -28,7 +30,6 @@ import {
 import { StandardParametersKey } from '../../../../src/types/ocpp/Configuration.js'
 import { Constants } from '../../../../src/utils/index.js'
 import { standardCleanup } from '../../../../tests/helpers/TestLifecycleHelpers.js'
-import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import {
   TEST_CHARGE_POINT_MODEL,
   TEST_CHARGE_POINT_SERIAL_NUMBER,
@@ -36,6 +37,7 @@ import {
   TEST_CHARGING_STATION_BASE_NAME,
   TEST_FIRMWARE_VERSION,
 } from '../../ChargingStationTestConstants.js'
+import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 
 await describe('B07 - Get Base Report', async () => {
   let station: ChargingStation
@@ -98,10 +100,7 @@ await describe('B07 - Get Base Report', async () => {
   })
 
   await it('should include registry variables with Actual attribute only for unsupported types', () => {
-    const reportData = testableService.buildReportData(
-      station,
-      ReportBaseEnumType.FullInventory
-    )
+    const reportData = testableService.buildReportData(station, ReportBaseEnumType.FullInventory)
     const heartbeatEntry = reportData.find(
       (item: ReportDataType) =>
         item.variable.name === (OCPP20OptionalVariableName.HeartbeatInterval as string) &&
@@ -208,10 +207,7 @@ await describe('B07 - Get Base Report', async () => {
 
   // FR: B08.FR.07
   await it('should build correct report data for FullInventory with station info', () => {
-    const reportData = testableService.buildReportData(
-      station,
-      ReportBaseEnumType.FullInventory
-    )
+    const reportData = testableService.buildReportData(station, ReportBaseEnumType.FullInventory)
 
     expect(Array.isArray(reportData)).toBe(true)
     expect(reportData.length).toBeGreaterThan(0)
@@ -240,10 +236,7 @@ await describe('B07 - Get Base Report', async () => {
 
   // FR: B08.FR.08
   await it('should build correct report data for SummaryInventory', () => {
-    const reportData = testableService.buildReportData(
-      station,
-      ReportBaseEnumType.SummaryInventory
-    )
+    const reportData = testableService.buildReportData(station, ReportBaseEnumType.SummaryInventory)
 
     expect(Array.isArray(reportData)).toBe(true)
     expect(reportData.length).toBeGreaterThan(0)
@@ -275,24 +268,18 @@ await describe('B07 - Get Base Report', async () => {
     // Use members exceeding 10 chars total; exclude removed RTC/Manual.
     const longValue = 'Heartbeat,NTP,GPS,RealTimeClock,MobileNetwork,RadioTimeTransmitter'
     // Set Actual (SequenceList). Should accept full value internally.
-    const setResult: OCPP20SetVariableResultType[] = variableManager.setVariables(
-      station,
-      [
-        {
-          attributeType: AttributeEnumType.Actual,
-          attributeValue: longValue,
-          component: { name: OCPP20ComponentName.ClockCtrlr },
-          variable: { name: OCPP20RequiredVariableName.TimeSource },
-        },
-      ]
-    )
+    const setResult: OCPP20SetVariableResultType[] = variableManager.setVariables(station, [
+      {
+        attributeType: AttributeEnumType.Actual,
+        attributeValue: longValue,
+        component: { name: OCPP20ComponentName.ClockCtrlr },
+        variable: { name: OCPP20RequiredVariableName.TimeSource },
+      },
+    ])
     expect(setResult[0].attributeStatus).toBe('Accepted')
 
     // Build report; value should be truncated to length 10
-    const reportData = testableService.buildReportData(
-      station,
-      ReportBaseEnumType.FullInventory
-    )
+    const reportData = testableService.buildReportData(station, ReportBaseEnumType.FullInventory)
     const timeSourceEntry = reportData.find(
       (item: ReportDataType) =>
         item.variable.name === (OCPP20RequiredVariableName.TimeSource as string) &&
index 74d2a6b67e5bf3ab7e4fcbf9894540776affb6a4..494815d4d09f0f08001e8d7ff64da9c52c5fff80 100644 (file)
@@ -6,6 +6,7 @@
 import { expect } from '@std/expect'
 import { afterEach, beforeEach, describe, it, mock } from 'node:test'
 
+import type { ChargingStation } from '../../../../src/charging-station/index.js'
 import type { ChargingStationWithCertificateManager } from '../../../../src/charging-station/ocpp/2.0/OCPP20CertificateManager.js'
 
 import { createTestableIncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/__testable__/index.js'
@@ -21,8 +22,8 @@ import {
   OCPPVersion,
 } from '../../../../src/types/index.js'
 import { Constants } from '../../../../src/utils/index.js'
-import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js'
+import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import { createStationWithCertificateManager } from './OCPP20TestUtils.js'
 
 const createMockCertificateHashData = (serialNumber = '123456789'): CertificateHashDataType => ({
@@ -256,7 +257,7 @@ await describe('I04 - GetInstalledCertificateIds', async () => {
 
   await describe('Certificate Manager Missing', async () => {
     await it('should return NotFound when certificate manager is not available', async () => {
-      const stationWithoutCertManager = createChargingStation({
+      const { station: stationWithoutCertManager } = createMockChargingStation({
         baseName: TEST_CHARGING_STATION_BASE_NAME,
         connectorsCount: 3,
         evseConfiguration: { evsesCount: 3 },
index b3164f1117daa48609d08261adafda97d1002eab..9ff24a46854c5e21c0ff9ad6a8326dfa4c6fcfd0 100644 (file)
@@ -25,7 +25,7 @@ import { standardCleanup } from '../../../../tests/helpers/TestLifecycleHelpers.
 import {
   TEST_CHARGING_STATION_BASE_NAME,
   TEST_CONNECTOR_ID_VALID_INSTANCE,
-  } from '../../ChargingStationTestConstants.js'
+} from '../../ChargingStationTestConstants.js'
 import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import {
   resetLimits,
index 36595afa0573293ba1df478c52b1a19be30ebf99..d396821da27d0c34f4050b08008cb8bf01e45128 100644 (file)
@@ -19,8 +19,8 @@ import {
   OCPPVersion,
 } from '../../../../src/types/index.js'
 import { Constants } from '../../../../src/utils/index.js'
-import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js'
+import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import { createStationWithCertificateManager } from './OCPP20TestUtils.js'
 
 const VALID_PEM_CERTIFICATE = `-----BEGIN CERTIFICATE-----
@@ -74,7 +74,6 @@ await describe('I03 - InstallCertificate', async () => {
     mock.restoreAll()
   })
 
-  let station: ChargingStation
   let mockChargingStation: ChargingStation
   let stationWithCertManager: ChargingStationWithCertificateManager
   let incomingRequestService: OCPP20IncomingRequestService
@@ -92,7 +91,7 @@ await describe('I03 - InstallCertificate', async () => {
       },
       websocketPingInterval: Constants.DEFAULT_WEBSOCKET_PING_INTERVAL,
     })
-    station = initialStation
+    mockChargingStation = initialStation
     mockChargingStation = initialStation
 
     // Use factory function to create station with certificate manager
index 355da7db35d1e3533ad219c17a439ca5a96838b0..80c724d27e545360f05f106dec312930fe8cb089 100644 (file)
@@ -23,8 +23,8 @@ import {
 } from '../../../../src/types/ocpp/2.0/Transaction.js'
 import { Constants } from '../../../../src/utils/index.js'
 import { standardCleanup } from '../../../../tests/helpers/TestLifecycleHelpers.js'
-import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js'
+import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import { createMockAuthService } from '../auth/helpers/MockFactories.js'
 import {
   resetConnectorTransactionState,
index 10a0aa6a78db43636f191c501e9ecf4a053c5c96..331f0cf47e3a0e24e9734e7c123e7c156750b6d2 100644 (file)
@@ -30,8 +30,8 @@ import {
 } from '../../../../src/types/ocpp/2.0/Transaction.js'
 import { Constants } from '../../../../src/utils/index.js'
 import { standardCleanup } from '../../../../tests/helpers/TestLifecycleHelpers.js'
-import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js'
+import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import { createMockAuthService } from '../auth/helpers/MockFactories.js'
 import {
   resetConnectorTransactionState,
@@ -308,7 +308,7 @@ await describe('F03 - Remote Stop Transaction', async () => {
   await it('should handle TransactionEvent request failure gracefully', async () => {
     sentTransactionEvents = []
 
-    const failingChargingStation = createChargingStation({
+    const { station: failingChargingStation } = createMockChargingStation({
       baseName: TEST_CHARGING_STATION_BASE_NAME + '-FAIL',
       connectorsCount: 1,
       evseConfiguration: { evsesCount: 1 },
index ac87da96e01912d979c7882589be68038af5f8e6..d16fc9423c92bf6e1d3160100212fe3d0181957b 100644 (file)
@@ -24,9 +24,9 @@ import {
   ResetStatusEnumType,
 } from '../../../../src/types/index.js'
 import { Constants } from '../../../../src/utils/index.js'
-import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import { standardCleanup } from '../../../helpers/TestLifecycleHelpers.js'
 import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js'
+import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 
 await describe('B11 & B12 - Reset', async () => {
   let mockChargingStation: ChargingStation
@@ -34,10 +34,6 @@ await describe('B11 & B12 - Reset', async () => {
     getNumberOfRunningTransactions: () => number
     reset: () => Promise<void>
   }
-  let mockStation: ReturnType<typeof createChargingStation> & {
-    getNumberOfRunningTransactions: () => number
-    reset: () => Promise<void>
-  }
   let incomingRequestService: OCPP20IncomingRequestService
   let testableService: ReturnType<typeof createTestableIncomingRequestService>
 
@@ -344,7 +340,7 @@ await describe('B11 & B12 - Reset', async () => {
       }
 
       const createTestStation = (): TestStation => {
-        const station = createChargingStation({
+        const { station } = createMockChargingStation({
           baseName: TEST_CHARGING_STATION_BASE_NAME,
           connectorsCount: 3,
           evseConfiguration: { evsesCount: 3 },
index cec05d4dac6829173adaed08be5fe2ff00186b8f..04dc8acc9bb0c6f51d348aef473c847fb495901b 100644 (file)
@@ -8,6 +8,7 @@ import { millisecondsToSeconds } from 'date-fns'
 import { afterEach, beforeEach, describe, it } from 'node:test'
 
 import type { ChargingStation } from '../../../../src/charging-station/index.js'
+
 import { createTestableIncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/__testable__/index.js'
 import { OCPP20IncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.js'
 import { OCPP20VariableManager } from '../../../../src/charging-station/ocpp/2.0/OCPP20VariableManager.js'
@@ -27,11 +28,11 @@ import {
 } from '../../../../src/types/index.js'
 import { Constants } from '../../../../src/utils/index.js'
 import { standardCleanup } from '../../../../tests/helpers/TestLifecycleHelpers.js'
-import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import {
   TEST_CHARGING_STATION_BASE_NAME,
   TEST_CONNECTOR_ID_VALID_INSTANCE,
 } from '../../ChargingStationTestConstants.js'
+import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import {
   resetLimits,
   resetValueSizeLimits,
index 727559744240123e94703bdcf9dddd989e921534..749406b99ca5975a179438e917479181340f91c6 100644 (file)
@@ -5,6 +5,8 @@
 import { expect } from '@std/expect'
 import { afterEach, beforeEach, describe, it, mock } from 'node:test'
 
+import type { ChargingStation } from '../../../../src/charging-station/index.js'
+
 import { OCPP20RequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20RequestService.js'
 import { OCPP20ResponseService } from '../../../../src/charging-station/ocpp/2.0/OCPP20ResponseService.js'
 import {
@@ -13,10 +15,8 @@ import {
   OCPP20RequestCommand,
   OCPPVersion,
 } from '../../../../src/types/index.js'
-import type { ChargingStation } from '../../../../src/charging-station/index.js'
 import { type ChargingStationType } from '../../../../src/types/ocpp/2.0/Common.js'
 import { Constants } from '../../../../src/utils/index.js'
-import { createMockChargingStation } from '../../../ChargingStationTestUtils.js'
 import {
   TEST_CHARGE_POINT_MODEL,
   TEST_CHARGE_POINT_SERIAL_NUMBER,
@@ -24,6 +24,7 @@ import {
   TEST_CHARGING_STATION_BASE_NAME,
   TEST_FIRMWARE_VERSION,
 } from '../../ChargingStationTestConstants.js'
+import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import {
   createTestableOCPP20RequestService,
   type TestableOCPP20RequestService,
@@ -173,7 +174,7 @@ await describe('B01 - Cold Boot Charging Station', async () => {
       }
 
       const payload = testableRequestService.buildRequestPayload(
-      station,
+        station,
         OCPP20RequestCommand.BOOT_NOTIFICATION,
         requestParams
       ) as OCPP20BootNotificationRequest
index aaebbd32be1216d0fbc4c15ba2a36cb462406ea1..3bcf51928eb87408ebfc6fd702be434c1764a380 100644 (file)
@@ -5,6 +5,8 @@
 import { expect } from '@std/expect'
 import { afterEach, beforeEach, describe, it, mock } from 'node:test'
 
+import type { ChargingStation } from '../../../../src/charging-station/index.js'
+
 import { OCPP20RequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20RequestService.js'
 import { OCPP20ResponseService } from '../../../../src/charging-station/ocpp/2.0/OCPP20ResponseService.js'
 import {
@@ -13,8 +15,6 @@ import {
   OCPPVersion,
 } from '../../../../src/types/index.js'
 import { Constants, has } from '../../../../src/utils/index.js'
-import { createMockChargingStation } from '../../../ChargingStationTestUtils.js'
-import type { ChargingStation } from '../../../../src/charging-station/index.js'
 import {
   TEST_CHARGE_POINT_MODEL,
   TEST_CHARGE_POINT_SERIAL_NUMBER,
@@ -22,6 +22,7 @@ import {
   TEST_CHARGING_STATION_BASE_NAME,
   TEST_FIRMWARE_VERSION,
 } from '../../ChargingStationTestConstants.js'
+import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import {
   createTestableOCPP20RequestService,
   type TestableOCPP20RequestService,
@@ -137,7 +138,7 @@ await describe('G02 - Heartbeat', async () => {
 
   // FR: G02.FR.05
   await it('should handle HeartBeat request with different charging station configurations', () => {
-    const alternativeChargingStation = createChargingStation({
+    const { station: alternativeChargingStation } = createMockChargingStation({
       baseName: 'CS-ALTERNATIVE-002',
       connectorsCount: 3,
       evseConfiguration: { evsesCount: 3 },
index 589d33930a13717e638e92d0cd7ddc74433588cb..f4bad7ba065d456449c38b0f763b290c3d2e8aaf 100644 (file)
@@ -210,10 +210,10 @@ await describe('M02 - Get15118EVCertificate Request', async () => {
 })
 
 await describe('M03 - GetCertificateStatus Request', async () => {
-  let station: TestChargingStation
+  let station: ReturnType<typeof createMockChargingStation>['station']
 
   beforeEach(() => {
-    station = createChargingStation({
+    const result = createMockChargingStation({
       baseName: TEST_CHARGING_STATION_BASE_NAME,
       connectorsCount: 3,
       evseConfiguration: { evsesCount: 3 },
@@ -224,6 +224,7 @@ await describe('M03 - GetCertificateStatus Request', async () => {
       },
       websocketPingInterval: Constants.DEFAULT_WEBSOCKET_PING_INTERVAL,
     })
+    station = result.station
   })
 
   afterEach(() => {
@@ -327,10 +328,10 @@ await describe('M03 - GetCertificateStatus Request', async () => {
 })
 
 await describe('Request Command Names', async () => {
-  let station: TestChargingStation
+  let station: ReturnType<typeof createMockChargingStation>['station']
 
   beforeEach(() => {
-    station = createChargingStation({
+    const result = createMockChargingStation({
       baseName: TEST_CHARGING_STATION_BASE_NAME,
       connectorsCount: 1,
       evseConfiguration: { evsesCount: 1 },
@@ -341,6 +342,7 @@ await describe('Request Command Names', async () => {
       },
       websocketPingInterval: Constants.DEFAULT_WEBSOCKET_PING_INTERVAL,
     })
+    station = result.station
   })
 
   afterEach(() => {
index d0692193475cc5bea7c4f06970974f8c47d2615f..bfb9e02c28c64a1dacb6a39bd55c287b2ead939e 100644 (file)
@@ -6,6 +6,8 @@
 import { expect } from '@std/expect'
 import { afterEach, beforeEach, describe, it, mock } from 'node:test'
 
+import type { ChargingStation } from '../../../../src/charging-station/index.js'
+
 import {
   createTestableRequestService,
   type TestableOCPP20RequestService,
@@ -22,8 +24,6 @@ import {
   type ReportDataType,
 } from '../../../../src/types/index.js'
 import { Constants } from '../../../../src/utils/index.js'
-import { createMockChargingStation } from '../../../ChargingStationTestUtils.js'
-import type { ChargingStation } from '../../../../src/charging-station/index.js'
 import {
   TEST_CHARGE_POINT_MODEL,
   TEST_CHARGE_POINT_SERIAL_NUMBER,
@@ -31,6 +31,7 @@ import {
   TEST_CHARGING_STATION_BASE_NAME,
   TEST_FIRMWARE_VERSION,
 } from '../../ChargingStationTestConstants.js'
+import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 
 await describe('B07/B08 - NotifyReport', async () => {
   let testableService: TestableOCPP20RequestService
index b896f1af607c676561243698da16b3b3aa0adc94..7ac34e19837740be52088d587e104ca3af7aeb35 100644 (file)
@@ -6,6 +6,8 @@
 import { expect } from '@std/expect'
 import { afterEach, beforeEach, describe, it, mock } from 'node:test'
 
+import type { ChargingStation } from '../../../../src/charging-station/index.js'
+
 import { createTestableRequestService } from '../../../../src/charging-station/ocpp/2.0/__testable__/index.js'
 import {
   CertificateSigningUseEnumType,
@@ -16,9 +18,8 @@ import {
   OCPPVersion,
 } from '../../../../src/types/index.js'
 import { Constants } from '../../../../src/utils/index.js'
-import { createMockChargingStation } from '../../../ChargingStationTestUtils.js'
-import type { ChargingStation } from '../../../../src/charging-station/index.js'
 import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js'
+import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 
 const MOCK_ORGANIZATION_NAME = 'Test Organization Inc.'
 
@@ -131,10 +132,7 @@ await describe('I02 - SignCertificate Request', async () => {
           },
         })
 
-      await service.requestSignCertificate(
-        station,
-        CertificateSigningUseEnumType.V2GCertificate
-      )
+      await service.requestSignCertificate(station, CertificateSigningUseEnumType.V2GCertificate)
 
       const sentPayload = sendMessageMock.mock.calls[0].arguments[2] as OCPP20SignCertificateRequest
 
@@ -247,7 +245,7 @@ await describe('I02 - SignCertificate Request', async () => {
 
   await describe('Error Handling', async () => {
     await it('should generate CSR without certificate manager dependency', async () => {
-      const stationWithoutCertManager = createChargingStation({
+      const { station: stationWithoutCertManager } = createMockChargingStation({
         baseName: TEST_CHARGING_STATION_BASE_NAME,
         connectorsCount: 1,
         evseConfiguration: { evsesCount: 1 },
index 8b8878ff204d24af3f3b4efee6167badffed4c02..3b31c6caff9496224e666a322b3cbf0ef946d4a1 100644 (file)
@@ -5,6 +5,8 @@
 import { expect } from '@std/expect'
 import { afterEach, beforeEach, describe, it, mock } from 'node:test'
 
+import type { ChargingStation } from '../../../../src/charging-station/index.js'
+
 import { OCPP20RequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20RequestService.js'
 import { OCPP20ResponseService } from '../../../../src/charging-station/ocpp/2.0/OCPP20ResponseService.js'
 import {
@@ -14,8 +16,6 @@ import {
   OCPPVersion,
 } from '../../../../src/types/index.js'
 import { Constants } from '../../../../src/utils/index.js'
-import { createMockChargingStation } from '../../../ChargingStationTestUtils.js'
-import type { ChargingStation } from '../../../../src/charging-station/index.js'
 import {
   TEST_FIRMWARE_VERSION,
   TEST_STATUS_CHARGE_POINT_MODEL,
@@ -23,6 +23,7 @@ import {
   TEST_STATUS_CHARGE_POINT_VENDOR,
   TEST_STATUS_CHARGING_STATION_BASE_NAME,
 } from '../../ChargingStationTestConstants.js'
+import { createMockChargingStation } from '../../ChargingStationTestUtils.js'
 import {
   createTestableOCPP20RequestService,
   type TestableOCPP20RequestService,
index 2bed59d4e532c425efa0a306f2656440b2266059..930c2b9dc09698f0611ba69d092089eef071eaad 100644 (file)
@@ -7,11 +7,12 @@ import { expect } from '@std/expect'
 import { millisecondsToSeconds } from 'date-fns'
 import { afterEach, beforeEach, describe, it } from 'node:test'
 
+import type { ChargingStation } from '../../../../src/charging-station/ChargingStation.js'
+
 import {
   deleteConfigurationKey,
   getConfigurationKey,
 } from '../../../../src/charging-station/ConfigurationKeyUtils.js'
-import type { ChargingStation } from '../../../../src/charging-station/ChargingStation.js'
 import { createTestableVariableManager } from '../../../../src/charging-station/ocpp/2.0/__testable__/index.js'
 import { OCPP20VariableManager } from '../../../../src/charging-station/ocpp/2.0/OCPP20VariableManager.js'
 import { VARIABLE_REGISTRY } from '../../../../src/charging-station/ocpp/2.0/OCPP20VariableRegistry.js'
index 5347d944de4a171107d59adfbde316d53bad774b..8fb6c63f170fece47d4ee852d8d50cd522102c82 100644 (file)
@@ -10,8 +10,8 @@ import type { AuthConfiguration } from '../../../../../src/charging-station/ocpp
 
 import { AuthComponentFactory } from '../../../../../src/charging-station/ocpp/auth/factories/AuthComponentFactory.js'
 import { OCPPVersion } from '../../../../../src/types/ocpp/OCPPVersion.js'
-import { createMockChargingStation } from '../../../ChargingStationTestUtils.js'
 import { standardCleanup } from '../../../../helpers/TestLifecycleHelpers.js'
+import { createMockChargingStation } from '../../../ChargingStationTestUtils.js'
 
 await describe('AuthComponentFactory', async () => {
   afterEach(() => {