]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor(tests): remove file-level eslint-disable and fix as any casts
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 28 Feb 2026 13:09:50 +0000 (14:09 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 28 Feb 2026 13:09:50 +0000 (14:09 +0100)
- Remove blanket eslint-disable comments from OCPP 2.0 test files
- Fix improper 'as any' casts in afterEach cleanup (use union types)
- Add targeted inline eslint-disable-next-line for legitimate test cases
  (testing null/undefined inputs for edge case validation)

tests/charging-station/ocpp/2.0/OCPP20CertificateManager.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RemoteStartAuth.test.ts

index b126c688f2308e8707d53d30edebe056760f66c8..ea73f677d7b5aaf0641467dc841a06b10c1a2489 100644 (file)
@@ -2,7 +2,6 @@
  * @file Tests for OCPP20CertificateManager
  * @description Unit tests for OCPP 2.0 certificate management and validation
  */
-/* eslint-disable @typescript-eslint/no-explicit-any */
 
 import { expect } from '@std/expect'
 import { rm } from 'node:fs/promises'
@@ -322,7 +321,9 @@ await describe('OCPP20CertificateManager', async () => {
     await it('should return false for null/undefined input', () => {
       const manager = new OCPP20CertificateManager()
 
+      // eslint-disable-next-line @typescript-eslint/no-explicit-any -- testing invalid null input
       expect(manager.validateCertificateFormat(null as any)).toBe(false)
+      // eslint-disable-next-line @typescript-eslint/no-explicit-any -- testing invalid undefined input
       expect(manager.validateCertificateFormat(undefined as any)).toBe(false)
     })
 
index 5d4b9e5ed49e25e32d7750f48b5c38dc86ba6c2b..eb510b71a90c97add04d49a1956c82f311cf29eb 100644 (file)
@@ -2,9 +2,6 @@
  * @file Tests for OCPP20IncomingRequestService RemoteStartAuth
  * @description Unit tests for OCPP 2.0 remote start pre-authorization (G03.FR.03)
  */
-/* eslint-disable @typescript-eslint/no-unsafe-assignment */
-
-/* eslint-disable @typescript-eslint/no-explicit-any */
 
 import { expect } from '@std/expect'
 import { afterEach, beforeEach, describe, it } from 'node:test'
@@ -28,8 +25,8 @@ import {
 import { OCPPVersion } from '../../../../src/types/ocpp/OCPPVersion.js'
 
 await describe('OCPP20IncomingRequestService - G03.FR.03 Remote Start Pre-Authorization', async () => {
-  let service: OCPP20IncomingRequestService
-  let mockChargingStation: ChargingStation
+  let service: OCPP20IncomingRequestService | undefined
+  let mockChargingStation: ChargingStation | undefined
 
   beforeEach(() => {
     // Mock charging station with EVSE configuration
@@ -64,8 +61,8 @@ await describe('OCPP20IncomingRequestService - G03.FR.03 Remote Start Pre-Author
 
   afterEach(() => {
     // Reset service and mock charging station state
-    mockChargingStation = undefined as any
-    service = undefined as any
+    mockChargingStation = undefined
+    service = undefined
   })
 
   await describe('G03.FR.03.001 - Successful remote start with valid token', async () => {
@@ -202,6 +199,7 @@ await describe('OCPP20IncomingRequestService - G03.FR.03 Remote Start Pre-Author
       // Given: Request without evseId (null)
 
       const request: OCPP20RequestStartTransactionRequest = {
+        // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any -- testing invalid null input
         evseId: null as any,
         idToken: {
           idToken: 'VALID_TOKEN_005',
@@ -218,6 +216,7 @@ await describe('OCPP20IncomingRequestService - G03.FR.03 Remote Start Pre-Author
       // Given: Request without evseId (undefined)
 
       const request: OCPP20RequestStartTransactionRequest = {
+        // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any -- testing invalid undefined input
         evseId: undefined as any,
         idToken: {
           idToken: 'VALID_TOKEN_006',