From: Jérôme Benoit Date: Sat, 28 Feb 2026 23:54:34 +0000 (+0100) Subject: fix(tests): remove unused mock imports after cleanup refactor X-Git-Tag: v3~54 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=98647fae65a0a23281c160bbd6be030ef7dc0073;p=e-mobility-charging-stations-simulator.git fix(tests): remove unused mock imports after cleanup refactor Removed ', mock' from imports in 31 test files where mock.restoreAll() was previously removed but the import remained, causing ESLint 'no-unused-vars' errors. --- diff --git a/tests/TEST_STYLE_GUIDE.md b/tests/TEST_STYLE_GUIDE.md index ec7bec7c..2ef5f334 100644 --- a/tests/TEST_STYLE_GUIDE.md +++ b/tests/TEST_STYLE_GUIDE.md @@ -257,13 +257,15 @@ expect(mocks.webSocket.sentMessages).toContain(expectedMessage) ### Lifecycle Helpers (`helpers/TestLifecycleHelpers.ts`) -| Utility | Purpose | -| --------------------------------- | ------------------------------------ | -| `standardCleanup()` | **MANDATORY** afterEach cleanup | -| `withMockTimers()` | Execute test with timer mocking | -| `createTimerScope()` | Manual timer control | -| `setupConnectorWithTransaction()` | Setup connector in transaction state | -| `clearConnectorTransaction()` | Clear connector transaction state | +| Utility | Purpose | +| --------------------------------- | ---------------------------------------- | +| `standardCleanup()` | **MANDATORY** afterEach cleanup | +| `withMockTimers()` | Execute test with timer mocking | +| `createTimerScope()` | Manual timer control | +| `createLoggerMocks()` | Create logger spies (error, warn) | +| `createConsoleMocks()` | Create console spies (error, warn, info) | +| `setupConnectorWithTransaction()` | Setup connector in transaction state | +| `clearConnectorTransaction()` | Clear connector transaction state | ### Mock Classes (`mocks/`) diff --git a/tests/charging-station/ConfigurationKeyUtils.test.ts b/tests/charging-station/ConfigurationKeyUtils.test.ts index b41f6fac..cd38d713 100644 --- a/tests/charging-station/ConfigurationKeyUtils.test.ts +++ b/tests/charging-station/ConfigurationKeyUtils.test.ts @@ -3,7 +3,7 @@ * @description Unit tests for OCPP configuration key management utilities */ import { expect } from '@std/expect' -import { afterEach, describe, it, mock } from 'node:test' +import { afterEach, describe, it } from 'node:test' import type { ChargingStationOcppConfiguration } from '../../src/types/index.js' @@ -25,7 +25,6 @@ const VALUE_B = 'ValueB' await describe('ConfigurationKeyUtils', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await describe('GetConfigurationKey', async () => { await it('should return undefined when configurationKey array is missing', () => { diff --git a/tests/charging-station/Helpers.test.ts b/tests/charging-station/Helpers.test.ts index f9e74aff..a778d26b 100644 --- a/tests/charging-station/Helpers.test.ts +++ b/tests/charging-station/Helpers.test.ts @@ -61,14 +61,12 @@ await describe('Helpers', async () => { }) as Reservation await it('should return formatted charging station ID with index', () => { - // Arrange & Act & Assert expect(getChargingStationId(1, chargingStationTemplate)).toBe( `${TEST_CHARGING_STATION_BASE_NAME}-00001` ) }) await it('should return consistent hash ID for same template and index', () => { - // Arrange & Act & Assert expect(getHashId(1, chargingStationTemplate)).toBe( 'b4b1e8ec4fca79091d99ea9a7ea5901548010e6c0e98be9296f604b9d68734444dfdae73d7d406b6124b42815214d088' ) @@ -488,7 +486,6 @@ await describe('Helpers', async () => { }) await it('should return correct phase rotation value for connector and phase count', () => { - // Arrange & Act & Assert expect(getPhaseRotationValue(0, 0)).toBe('0.RST') expect(getPhaseRotationValue(1, 0)).toBe('1.NotApplicable') expect(getPhaseRotationValue(2, 0)).toBe('2.NotApplicable') @@ -504,7 +501,6 @@ await describe('Helpers', async () => { }) await it('should return -1 for undefined EVSEs and 0 for empty object', () => { - // Arrange & Act & Assert expect(getMaxNumberOfEvses(undefined)).toBe(-1) expect(getMaxNumberOfEvses({})).toBe(0) }) @@ -664,35 +660,29 @@ await describe('Helpers', async () => { // Tests for reservation helper functions await it('should return true when reservation has expired', () => { - // Arrange & Act & Assert expect(hasReservationExpired(createTestReservation(true))).toBe(true) }) await it('should return false when reservation is still valid', () => { - // Arrange & Act & Assert expect(hasReservationExpired(createTestReservation(false))).toBe(false) }) await it('should return false when connector has no reservation', () => { - // Arrange & Act & Assert const connectorStatus = {} as ConnectorStatus expect(hasPendingReservation(connectorStatus)).toBe(false) }) await it('should return true when connector has valid pending reservation', () => { - // Arrange & Act & Assert const connectorStatus = { reservation: createTestReservation(false) } as ConnectorStatus expect(hasPendingReservation(connectorStatus)).toBe(true) }) await it('should return false when connector reservation has expired', () => { - // Arrange & Act & Assert const connectorStatus = { reservation: createTestReservation(true) } as ConnectorStatus expect(hasPendingReservation(connectorStatus)).toBe(false) }) await it('should return false when no reservations exist (connector mode)', () => { - // Arrange & Act & Assert const { station: chargingStation } = createMockChargingStation({ connectorsCount: 2, TEST_CHARGING_STATION_BASE_NAME, diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CertificateSigned.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CertificateSigned.test.ts index dc884220..b9f94c39 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CertificateSigned.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-CertificateSigned.test.ts @@ -85,7 +85,6 @@ await describe('I04 - CertificateSigned', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await describe('Valid Certificate Chain Installation', async () => { await it('should accept valid certificate chain', async () => { diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts index d4ad89d7..9d47f93b 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-ClearCache.test.ts @@ -4,7 +4,7 @@ */ import { expect } from '@std/expect' -import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import type { ChargingStation } from '../../../../src/charging-station/index.js' @@ -20,7 +20,6 @@ import { createMockChargingStation } from '../../ChargingStationTestUtils.js' await describe('C11 - Clear Authorization Data in Authorization Cache', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) let station: ChargingStation diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DeleteCertificate.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DeleteCertificate.test.ts index 9a9f496e..5d0317b0 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DeleteCertificate.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-DeleteCertificate.test.ts @@ -4,7 +4,7 @@ */ import { expect } from '@std/expect' -import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import type { ChargingStation } from '../../../../src/charging-station/index.js' import type { ChargingStationWithCertificateManager } from '../../../../src/charging-station/ocpp/2.0/OCPP20CertificateManager.js' @@ -45,7 +45,6 @@ const NONEXISTENT_CERTIFICATE_HASH_DATA = { await describe('I04 - DeleteCertificate', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) let station: ChargingStation diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetInstalledCertificateIds.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetInstalledCertificateIds.test.ts index 98178b23..4bd9651f 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetInstalledCertificateIds.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetInstalledCertificateIds.test.ts @@ -4,7 +4,7 @@ */ import { expect } from '@std/expect' -import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import type { ChargingStation } from '../../../../src/charging-station/index.js' import type { ChargingStationWithCertificateManager } from '../../../../src/charging-station/ocpp/2.0/OCPP20CertificateManager.js' @@ -76,7 +76,6 @@ await describe('I04 - GetInstalledCertificateIds', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await describe('Request All Certificate Types', async () => { diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-InstallCertificate.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-InstallCertificate.test.ts index 750d095f..3a2e6ce2 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-InstallCertificate.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-InstallCertificate.test.ts @@ -4,7 +4,7 @@ */ import { expect } from '@std/expect' -import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import type { ChargingStation } from '../../../../src/charging-station/index.js' import type { ChargingStationWithCertificateManager } from '../../../../src/charging-station/ocpp/2.0/OCPP20CertificateManager.js' @@ -55,7 +55,6 @@ SIb3DQEBCwUAA0EAexpired== await describe('I03 - InstallCertificate', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) let mockChargingStation: ChargingStation diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-BootNotification.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-BootNotification.test.ts index 456381c1..597aa22c 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-BootNotification.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-BootNotification.test.ts @@ -3,7 +3,7 @@ * @description Unit tests for OCPP 2.0 BootNotification request building (B01) */ import { expect } from '@std/expect' -import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import type { ChargingStation } from '../../../../src/charging-station/index.js' @@ -61,7 +61,6 @@ await describe('B01 - Cold Boot Charging Station', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) // FR: B01.FR.01 diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-HeartBeat.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-HeartBeat.test.ts index 00b1c0e1..c954292a 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-HeartBeat.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-HeartBeat.test.ts @@ -3,7 +3,7 @@ * @description Unit tests for OCPP 2.0 Heartbeat request building (G02) */ import { expect } from '@std/expect' -import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import type { ChargingStation } from '../../../../src/charging-station/index.js' @@ -59,7 +59,6 @@ await describe('G02 - Heartbeat', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) // FR: G02.FR.01 diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-ISO15118.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-ISO15118.test.ts index dae44e14..c9662210 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-ISO15118.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-ISO15118.test.ts @@ -5,7 +5,7 @@ /* cspell:ignore Bvbn NQIF CBCYX */ import { expect } from '@std/expect' -import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import { createTestableRequestService } from '../../../../src/charging-station/ocpp/2.0/__testable__/index.js' import { @@ -62,7 +62,6 @@ await describe('M02 - Get15118EVCertificate Request', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await describe('EXI Install Action', async () => { @@ -231,7 +230,6 @@ await describe('M03 - GetCertificateStatus Request', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await describe('OCSP Request Data', async () => { @@ -350,7 +348,6 @@ await describe('Request Command Names', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await it('should send GET_15118_EV_CERTIFICATE command name', async () => { diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts index bd50afd5..f9eea7ad 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts @@ -4,7 +4,7 @@ */ import { expect } from '@std/expect' -import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import type { ChargingStation } from '../../../../src/charging-station/index.js' @@ -61,7 +61,6 @@ await describe('B07/B08 - NotifyReport', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) // FR: B07.FR.03, B07.FR.04 diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-SignCertificate.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-SignCertificate.test.ts index 6fd5192c..ddd45116 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-SignCertificate.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-SignCertificate.test.ts @@ -4,7 +4,7 @@ */ import { expect } from '@std/expect' -import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import type { ChargingStation } from '../../../../src/charging-station/index.js' @@ -48,7 +48,6 @@ await describe('I02 - SignCertificate Request', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await describe('CSR Generation', async () => { diff --git a/tests/charging-station/ocpp/2.0/OCPP20RequestService-StatusNotification.test.ts b/tests/charging-station/ocpp/2.0/OCPP20RequestService-StatusNotification.test.ts index 00c61824..0084586d 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20RequestService-StatusNotification.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20RequestService-StatusNotification.test.ts @@ -3,7 +3,7 @@ * @description Unit tests for OCPP 2.0 StatusNotification request building (G01) */ import { expect } from '@std/expect' -import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import type { ChargingStation } from '../../../../src/charging-station/index.js' @@ -60,7 +60,6 @@ await describe('G01 - Status Notification', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) // FR: G01.FR.01 diff --git a/tests/charging-station/ocpp/auth/OCPPAuthIntegration.test.ts b/tests/charging-station/ocpp/auth/OCPPAuthIntegration.test.ts index 8f57ff78..ac717a90 100644 --- a/tests/charging-station/ocpp/auth/OCPPAuthIntegration.test.ts +++ b/tests/charging-station/ocpp/auth/OCPPAuthIntegration.test.ts @@ -4,7 +4,7 @@ */ import { expect } from '@std/expect' -import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import type { ChargingStation } from '../../../../src/charging-station/ChargingStation.js' @@ -51,7 +51,6 @@ await describe('OCPP Authentication', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await describe('OCPP 1.6 Authentication', async () => { diff --git a/tests/charging-station/ocpp/auth/adapters/OCPP16AuthAdapter.test.ts b/tests/charging-station/ocpp/auth/adapters/OCPP16AuthAdapter.test.ts index 1b958188..a5a586b8 100644 --- a/tests/charging-station/ocpp/auth/adapters/OCPP16AuthAdapter.test.ts +++ b/tests/charging-station/ocpp/auth/adapters/OCPP16AuthAdapter.test.ts @@ -3,7 +3,7 @@ * @description Unit tests for OCPP 1.6 authentication adapter */ import { expect } from '@std/expect' -import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import type { ChargingStation } from '../../../../../src/charging-station/ChargingStation.js' import type { OCPP16AuthorizeResponse } from '../../../../../src/types/ocpp/1.6/Responses.js' @@ -55,7 +55,6 @@ await describe('OCPP16AuthAdapter', async () => { }) afterEach(() => { - mock.restoreAll() standardCleanup() }) diff --git a/tests/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.test.ts b/tests/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.test.ts index 28b8566d..cc6feba5 100644 --- a/tests/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.test.ts +++ b/tests/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.test.ts @@ -42,7 +42,6 @@ await describe('OCPP20AuthAdapter', async () => { }) afterEach(() => { - mock.restoreAll() standardCleanup() }) diff --git a/tests/charging-station/ocpp/auth/cache/InMemoryAuthCache.test.ts b/tests/charging-station/ocpp/auth/cache/InMemoryAuthCache.test.ts index 470b952a..9d79a941 100644 --- a/tests/charging-station/ocpp/auth/cache/InMemoryAuthCache.test.ts +++ b/tests/charging-station/ocpp/auth/cache/InMemoryAuthCache.test.ts @@ -3,7 +3,7 @@ * @description Unit tests for in-memory authorization cache conformance (G03.FR.01) */ import { expect } from '@std/expect' -import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import type { AuthorizationResult } from '../../../../../src/charging-station/ocpp/auth/types/AuthTypes.js' @@ -43,7 +43,6 @@ await describe('InMemoryAuthCache - G03.FR.01 Conformance', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await describe('G03.FR.01.001 - Cache Hit Behavior', async () => { diff --git a/tests/charging-station/ocpp/auth/strategies/CertificateAuthStrategy.test.ts b/tests/charging-station/ocpp/auth/strategies/CertificateAuthStrategy.test.ts index 38562548..6fef9114 100644 --- a/tests/charging-station/ocpp/auth/strategies/CertificateAuthStrategy.test.ts +++ b/tests/charging-station/ocpp/auth/strategies/CertificateAuthStrategy.test.ts @@ -3,7 +3,7 @@ * @description Unit tests for certificate-based authentication strategy */ import { expect } from '@std/expect' -import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import type { ChargingStation } from '../../../../../src/charging-station/ChargingStation.js' import type { OCPPAuthAdapter } from '../../../../../src/charging-station/ocpp/auth/interfaces/OCPPAuthService.js' @@ -58,7 +58,6 @@ await describe('CertificateAuthStrategy', async () => { }) afterEach(() => { - mock.restoreAll() standardCleanup() }) diff --git a/tests/charging-station/ocpp/auth/strategies/LocalAuthStrategy.test.ts b/tests/charging-station/ocpp/auth/strategies/LocalAuthStrategy.test.ts index acdecb62..8d891f5d 100644 --- a/tests/charging-station/ocpp/auth/strategies/LocalAuthStrategy.test.ts +++ b/tests/charging-station/ocpp/auth/strategies/LocalAuthStrategy.test.ts @@ -3,7 +3,7 @@ * @description Unit tests for local authorization strategy (cache and local list) */ import { expect } from '@std/expect' -import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import type { AuthCache, @@ -40,7 +40,6 @@ await describe('LocalAuthStrategy', async () => { }) afterEach(() => { - mock.restoreAll() standardCleanup() }) @@ -102,19 +101,6 @@ await describe('LocalAuthStrategy', async () => { await strategy.initialize(config) }) - afterEach(() => { - // Reset mock properties to prevent state pollution between tests - // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access - delete (mockLocalAuthListManager as any).getEntry - // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access - delete (mockAuthCache as any).get - // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access - delete (mockAuthCache as any).set - // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access - delete (mockAuthCache as any).remove - mock.restoreAll() - }) - await it('should authenticate using local auth list', async () => { mockLocalAuthListManager.getEntry = async () => await Promise.resolve({ diff --git a/tests/charging-station/ocpp/auth/strategies/RemoteAuthStrategy.test.ts b/tests/charging-station/ocpp/auth/strategies/RemoteAuthStrategy.test.ts index 3727f3b4..d75964a4 100644 --- a/tests/charging-station/ocpp/auth/strategies/RemoteAuthStrategy.test.ts +++ b/tests/charging-station/ocpp/auth/strategies/RemoteAuthStrategy.test.ts @@ -3,7 +3,7 @@ * @description Unit tests for remote (CSMS) authorization strategy */ import { expect } from '@std/expect' -import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import type { AuthCache, @@ -45,7 +45,6 @@ await describe('RemoteAuthStrategy', async () => { }) afterEach(() => { - mock.restoreAll() standardCleanup() }) diff --git a/tests/charging-station/ocpp/auth/types/AuthTypes.test.ts b/tests/charging-station/ocpp/auth/types/AuthTypes.test.ts index 7d993f61..37aee643 100644 --- a/tests/charging-station/ocpp/auth/types/AuthTypes.test.ts +++ b/tests/charging-station/ocpp/auth/types/AuthTypes.test.ts @@ -3,7 +3,7 @@ * @description Unit tests for authentication type definitions and mappings */ import { expect } from '@std/expect' -import { afterEach, describe, it, mock } from 'node:test' +import { afterEach, describe, it } from 'node:test' import { AuthContext, @@ -34,7 +34,6 @@ import { standardCleanup } from '../../../../helpers/TestLifecycleHelpers.js' await describe('AuthTypes', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await describe('IdentifierTypeGuards', async () => { await it('should correctly identify OCPP 1.6 types', () => { diff --git a/tests/charging-station/ocpp/auth/utils/AuthHelpers.test.ts b/tests/charging-station/ocpp/auth/utils/AuthHelpers.test.ts index c2a7f031..c88a894b 100644 --- a/tests/charging-station/ocpp/auth/utils/AuthHelpers.test.ts +++ b/tests/charging-station/ocpp/auth/utils/AuthHelpers.test.ts @@ -3,7 +3,7 @@ * @description Unit tests for authentication helper utilities */ import { expect } from '@std/expect' -import { afterEach, describe, it, mock } from 'node:test' +import { afterEach, describe, it } from 'node:test' import { AuthContext, @@ -20,7 +20,6 @@ import { standardCleanup } from '../../../../helpers/TestLifecycleHelpers.js' await describe('AuthHelpers', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await describe('calculateTTL', async () => { await it('should return undefined for undefined expiry date', () => { diff --git a/tests/charging-station/ocpp/auth/utils/AuthValidators.test.ts b/tests/charging-station/ocpp/auth/utils/AuthValidators.test.ts index ac6b6c40..5279ea41 100644 --- a/tests/charging-station/ocpp/auth/utils/AuthValidators.test.ts +++ b/tests/charging-station/ocpp/auth/utils/AuthValidators.test.ts @@ -3,7 +3,7 @@ * @description Unit tests for authentication validation utilities */ import { expect } from '@std/expect' -import { afterEach, describe, it, mock } from 'node:test' +import { afterEach, describe, it } from 'node:test' import { type AuthConfiguration, @@ -18,7 +18,6 @@ import { standardCleanup } from '../../../../helpers/TestLifecycleHelpers.js' await describe('AuthValidators', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await describe('isValidCacheTTL', async () => { await it('should return true for undefined TTL', () => { diff --git a/tests/charging-station/ocpp/auth/utils/ConfigValidator.test.ts b/tests/charging-station/ocpp/auth/utils/ConfigValidator.test.ts index d1a4c739..fb9d91fb 100644 --- a/tests/charging-station/ocpp/auth/utils/ConfigValidator.test.ts +++ b/tests/charging-station/ocpp/auth/utils/ConfigValidator.test.ts @@ -5,7 +5,7 @@ // Copyright Jerome Benoit. 2021-2025. All Rights Reserved. import { expect } from '@std/expect' -import { afterEach, describe, it, mock } from 'node:test' +import { afterEach, describe, it } from 'node:test' import { type AuthConfiguration, @@ -18,7 +18,6 @@ import { standardCleanup } from '../../../../helpers/TestLifecycleHelpers.js' await describe('AuthConfigValidator', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await describe('validate', async () => { await it('should accept valid configuration', () => { diff --git a/tests/charging-station/ui-server/UIHttpServer.test.ts b/tests/charging-station/ui-server/UIHttpServer.test.ts index 209e21f0..8a36beed 100644 --- a/tests/charging-station/ui-server/UIHttpServer.test.ts +++ b/tests/charging-station/ui-server/UIHttpServer.test.ts @@ -5,7 +5,7 @@ // Copyright Jerome Benoit. 2024-2025. All Rights Reserved. import { expect } from '@std/expect' -import { afterEach, beforeEach, describe, it, mock } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import { gunzipSync } from 'node:zlib' import type { UUIDv4 } from '../../../src/types/index.js' @@ -55,7 +55,6 @@ await describe('UIHttpServer', async () => { }) afterEach(() => { - mock.restoreAll() standardCleanup() }) @@ -196,7 +195,6 @@ await describe('UIHttpServer', async () => { }) afterEach(() => { - mock.restoreAll() standardCleanup() }) diff --git a/tests/charging-station/ui-server/UIServerSecurity.test.ts b/tests/charging-station/ui-server/UIServerSecurity.test.ts index cd07d238..e2db4bee 100644 --- a/tests/charging-station/ui-server/UIServerSecurity.test.ts +++ b/tests/charging-station/ui-server/UIServerSecurity.test.ts @@ -5,7 +5,7 @@ // Copyright Jerome Benoit. 2024-2025. All Rights Reserved. import { expect } from '@std/expect' -import { afterEach, describe, it, mock } from 'node:test' +import { afterEach, describe, it } from 'node:test' import { createBodySizeLimiter, @@ -21,7 +21,6 @@ const RATE_WINDOW_EXPIRY_DELAY_MS = 110 await describe('UIServerSecurity', async () => { afterEach(() => { - mock.restoreAll() standardCleanup() }) await describe('IsValidCredential', async () => { diff --git a/tests/charging-station/ui-server/UIWebSocketServer.test.ts b/tests/charging-station/ui-server/UIWebSocketServer.test.ts index 216237aa..950cd105 100644 --- a/tests/charging-station/ui-server/UIWebSocketServer.test.ts +++ b/tests/charging-station/ui-server/UIWebSocketServer.test.ts @@ -5,7 +5,7 @@ // Copyright Jerome Benoit. 2024-2025. All Rights Reserved. import { expect } from '@std/expect' -import { afterEach, describe, it, mock } from 'node:test' +import { afterEach, describe, it } from 'node:test' import type { UUIDv4 } from '../../../src/types/index.js' @@ -22,7 +22,6 @@ import { await describe('UIWebSocketServer', async () => { afterEach(() => { - mock.restoreAll() standardCleanup() }) await it('should delete response handler after successful send', () => { diff --git a/tests/charging-station/ui-server/ui-services/AbstractUIService.test.ts b/tests/charging-station/ui-server/ui-services/AbstractUIService.test.ts index 15593330..238d5a1c 100644 --- a/tests/charging-station/ui-server/ui-services/AbstractUIService.test.ts +++ b/tests/charging-station/ui-server/ui-services/AbstractUIService.test.ts @@ -5,7 +5,7 @@ // Copyright Jerome Benoit. 2024-2025. All Rights Reserved. import { expect } from '@std/expect' -import { afterEach, describe, it, mock } from 'node:test' +import { afterEach, describe, it } from 'node:test' import { ProcedureName, ProtocolVersion, ResponseStatus } from '../../../../src/types/index.js' import { standardCleanup } from '../../../helpers/TestLifecycleHelpers.js' @@ -19,7 +19,6 @@ import { await describe('AbstractUIService', async () => { afterEach(() => { - mock.restoreAll() standardCleanup() }) await it('should check response handler existence before sending', () => { diff --git a/tests/exception/BaseError.test.ts b/tests/exception/BaseError.test.ts index a4271d14..f7d4fd49 100644 --- a/tests/exception/BaseError.test.ts +++ b/tests/exception/BaseError.test.ts @@ -3,7 +3,7 @@ * @description Unit tests for base error class functionality */ import { expect } from '@std/expect' -import { afterEach, describe, it, mock } from 'node:test' +import { afterEach, describe, it } from 'node:test' import { BaseError } from '../../src/exception/BaseError.js' import { standardCleanup } from '../helpers/TestLifecycleHelpers.js' @@ -11,7 +11,6 @@ import { standardCleanup } from '../helpers/TestLifecycleHelpers.js' await describe('BaseError', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await it('should create instance with default values', () => { const baseError = new BaseError() diff --git a/tests/exception/OCPPError.test.ts b/tests/exception/OCPPError.test.ts index a1bb50f2..5c07bd9c 100644 --- a/tests/exception/OCPPError.test.ts +++ b/tests/exception/OCPPError.test.ts @@ -3,7 +3,7 @@ * @description Unit tests for OCPP-specific error class */ import { expect } from '@std/expect' -import { afterEach, describe, it, mock } from 'node:test' +import { afterEach, describe, it } from 'node:test' import { OCPPError } from '../../src/exception/OCPPError.js' import { ErrorType } from '../../src/types/index.js' @@ -13,7 +13,6 @@ import { standardCleanup } from '../helpers/TestLifecycleHelpers.js' await describe('OCPPError', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await it('should create instance with error code and default values', () => { diff --git a/tests/types/ConfigurationData.test.ts b/tests/types/ConfigurationData.test.ts index a12b970f..f0bed3ca 100644 --- a/tests/types/ConfigurationData.test.ts +++ b/tests/types/ConfigurationData.test.ts @@ -3,7 +3,7 @@ * @description Unit tests for configuration data types and enumerations */ import { expect } from '@std/expect' -import { afterEach, describe, it, mock } from 'node:test' +import { afterEach, describe, it } from 'node:test' import { ApplicationProtocolVersion, @@ -15,7 +15,6 @@ import { standardCleanup } from '../helpers/TestLifecycleHelpers.js' await describe('ConfigurationData', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await it('should define ConfigurationSection enumeration values', () => { diff --git a/tests/utils/AsyncLock.test.ts b/tests/utils/AsyncLock.test.ts index 943216c5..cb5f39cf 100644 --- a/tests/utils/AsyncLock.test.ts +++ b/tests/utils/AsyncLock.test.ts @@ -4,7 +4,7 @@ */ import { expect } from '@std/expect' import { randomInt } from 'node:crypto' -import { afterEach, describe, it, mock } from 'node:test' +import { afterEach, describe, it } from 'node:test' import { AsyncLock, AsyncLockType } from '../../src/utils/AsyncLock.js' import { standardCleanup } from '../helpers/TestLifecycleHelpers.js' @@ -12,7 +12,6 @@ import { standardCleanup } from '../helpers/TestLifecycleHelpers.js' await describe('AsyncLock', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await it('should run synchronous functions exclusively in sequence', () => { const runs = 10 diff --git a/tests/utils/ElectricUtils.test.ts b/tests/utils/ElectricUtils.test.ts index 251206a5..232b09c7 100644 --- a/tests/utils/ElectricUtils.test.ts +++ b/tests/utils/ElectricUtils.test.ts @@ -3,7 +3,7 @@ * @description Unit tests for electrical calculations (AC/DC power, amperage) */ import { expect } from '@std/expect' -import { afterEach, describe, it, mock } from 'node:test' +import { afterEach, describe, it } from 'node:test' import { ACElectricUtils, DCElectricUtils } from '../../src/utils/ElectricUtils.js' import { standardCleanup } from '../helpers/TestLifecycleHelpers.js' @@ -11,7 +11,6 @@ import { standardCleanup } from '../helpers/TestLifecycleHelpers.js' await describe('ElectricUtils', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await it('should calculate DC power from voltage and current', () => { expect(DCElectricUtils.power(230, 1)).toBe(230) diff --git a/tests/utils/StatisticUtils.test.ts b/tests/utils/StatisticUtils.test.ts index 05bd6cc4..211524b6 100644 --- a/tests/utils/StatisticUtils.test.ts +++ b/tests/utils/StatisticUtils.test.ts @@ -3,7 +3,7 @@ * @description Unit tests for statistical calculation utilities */ import { expect } from '@std/expect' -import { afterEach, describe, it, mock } from 'node:test' +import { afterEach, describe, it } from 'node:test' import { average, max, median, min, percentile, std } from '../../src/utils/StatisticUtils.js' import { standardCleanup } from '../helpers/TestLifecycleHelpers.js' @@ -11,7 +11,6 @@ import { standardCleanup } from '../helpers/TestLifecycleHelpers.js' await describe('StatisticUtils', async () => { afterEach(() => { standardCleanup() - mock.restoreAll() }) await it('should calculate arithmetic mean of array values', () => { expect(average([])).toBe(0)