From: Jérôme Benoit Date: Fri, 13 Mar 2026 16:29:36 +0000 (+0100) Subject: test: remove 24 tautological enum value assertion tests X-Git-Tag: ocpp-server@v3.1.0~48 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ba22a74942941bb9f113fd31836d5cc2bab7576d;p=e-mobility-charging-stations-simulator.git test: remove 24 tautological enum value assertion tests Remove tests that assert compile-time constant enum values (e.g. EnumName.MEMBER === 'hardcodedString'), which always pass by definition and exercise no production code. - Delete ConfigurationData.test.ts (3 tautological tests) - Remove ProcedureName/BroadcastChannelProcedureName enum groups (16 tests) - Remove AuthTypes Enums block (4 tests) - Remove OutputFormat enum test (1 test) - Fix assert.strictEqual(true, false) to assert.fail() in OCPPAuthServiceFactory All quality gates pass. Coverage unchanged (1800 tests, 0 failures). --- diff --git a/tests/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.test.ts b/tests/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.test.ts index e6d9281c..c8f743cb 100644 --- a/tests/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.test.ts +++ b/tests/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.test.ts @@ -1,8 +1,8 @@ /** * @file Tests for ChargingStationWorkerBroadcastChannel - * @description Verifies OCPP 2.0.1 UIService pipeline integration: enums, mappings, + * @description Verifies OCPP 2.0.1 UIService pipeline integration: mappings, * response status logic, payload building, and handler routing for the 8 new broadcast - * channel procedures. 59 tests across 7 groups. + * channel procedures. */ import assert from 'node:assert/strict' @@ -104,98 +104,7 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { }) // ========================================================================== - // Group 1: ProcedureName enum — 8 new OCPP 2.0.1 entries (8 tests) - // ========================================================================== - - await describe('ProcedureName enum OCPP 2.0.1 entries', async () => { - await it('should have GET_15118_EV_CERTIFICATE in ProcedureName enum', () => { - assert.strictEqual(ProcedureName.GET_15118_EV_CERTIFICATE, 'get15118EVCertificate') - }) - - await it('should have GET_CERTIFICATE_STATUS in ProcedureName enum', () => { - assert.strictEqual(ProcedureName.GET_CERTIFICATE_STATUS, 'getCertificateStatus') - }) - - await it('should have LOG_STATUS_NOTIFICATION in ProcedureName enum', () => { - assert.strictEqual(ProcedureName.LOG_STATUS_NOTIFICATION, 'logStatusNotification') - }) - - await it('should have NOTIFY_CUSTOMER_INFORMATION in ProcedureName enum', () => { - assert.strictEqual(ProcedureName.NOTIFY_CUSTOMER_INFORMATION, 'notifyCustomerInformation') - }) - - await it('should have NOTIFY_REPORT in ProcedureName enum', () => { - assert.strictEqual(ProcedureName.NOTIFY_REPORT, 'notifyReport') - }) - - await it('should have SECURITY_EVENT_NOTIFICATION in ProcedureName enum', () => { - assert.strictEqual(ProcedureName.SECURITY_EVENT_NOTIFICATION, 'securityEventNotification') - }) - - await it('should have SIGN_CERTIFICATE in ProcedureName enum', () => { - assert.strictEqual(ProcedureName.SIGN_CERTIFICATE, 'signCertificate') - }) - - await it('should have TRANSACTION_EVENT in ProcedureName enum', () => { - assert.strictEqual(ProcedureName.TRANSACTION_EVENT, 'transactionEvent') - }) - }) - - // ========================================================================== - // Group 2: BroadcastChannelProcedureName enum — 8 new OCPP 2.0.1 entries (8 tests) - // ========================================================================== - - await describe('BroadcastChannelProcedureName enum OCPP 2.0.1 entries', async () => { - await it('should have GET_15118_EV_CERTIFICATE in BroadcastChannelProcedureName enum', () => { - assert.strictEqual( - BroadcastChannelProcedureName.GET_15118_EV_CERTIFICATE, - 'get15118EVCertificate' - ) - }) - - await it('should have GET_CERTIFICATE_STATUS in BroadcastChannelProcedureName enum', () => { - assert.strictEqual( - BroadcastChannelProcedureName.GET_CERTIFICATE_STATUS, - 'getCertificateStatus' - ) - }) - - await it('should have LOG_STATUS_NOTIFICATION in BroadcastChannelProcedureName enum', () => { - assert.strictEqual( - BroadcastChannelProcedureName.LOG_STATUS_NOTIFICATION, - 'logStatusNotification' - ) - }) - - await it('should have NOTIFY_CUSTOMER_INFORMATION in BroadcastChannelProcedureName enum', () => { - assert.strictEqual( - BroadcastChannelProcedureName.NOTIFY_CUSTOMER_INFORMATION, - 'notifyCustomerInformation' - ) - }) - - await it('should have NOTIFY_REPORT in BroadcastChannelProcedureName enum', () => { - assert.strictEqual(BroadcastChannelProcedureName.NOTIFY_REPORT, 'notifyReport') - }) - - await it('should have SECURITY_EVENT_NOTIFICATION in BroadcastChannelProcedureName enum', () => { - assert.strictEqual( - BroadcastChannelProcedureName.SECURITY_EVENT_NOTIFICATION, - 'securityEventNotification' - ) - }) - - await it('should have SIGN_CERTIFICATE in BroadcastChannelProcedureName enum', () => { - assert.strictEqual(BroadcastChannelProcedureName.SIGN_CERTIFICATE, 'signCertificate') - }) - - await it('should have TRANSACTION_EVENT in BroadcastChannelProcedureName enum', () => { - assert.strictEqual(BroadcastChannelProcedureName.TRANSACTION_EVENT, 'transactionEvent') - }) - }) - - // ========================================================================== - // Group 3: ProcedureNameToBroadCastChannelProcedureNameMapping — 8 new entries (8 tests) + // Group 1: ProcedureNameToBroadCastChannelProcedureNameMapping — 8 new entries (8 tests) // ========================================================================== await describe('ProcedureNameToBroadCastChannelProcedureNameMapping OCPP 2.0.1 entries', async () => { @@ -265,7 +174,7 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { }) // ========================================================================== - // Group 4: commandResponseToResponseStatus — 4 new command response cases (18 tests) + // Group 2: commandResponseToResponseStatus — 4 new command response cases (18 tests) // ========================================================================== await describe('commandResponseToResponseStatus OCPP 2.0.1 commands', async () => { @@ -625,7 +534,7 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { }) // ========================================================================== - // Group 5: buildRequestPayload — OCPP 2.0.1 certificate passthrough (3 tests) + // Group 3: buildRequestPayload — OCPP 2.0.1 certificate passthrough (3 tests) // ========================================================================== await describe('buildRequestPayload OCPP 2.0.1 certificate passthrough', async () => { @@ -684,7 +593,7 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { }) // ========================================================================== - // Group 6: commandHandler dispatch pipeline — verify full dispatch (8 tests) + // Group 4: commandHandler dispatch pipeline — verify full dispatch (8 tests) // ========================================================================== await describe('commandHandler OCPP 2.0.1 dispatch pipeline', async () => { @@ -786,7 +695,7 @@ await describe('ChargingStationWorkerBroadcastChannel', async () => { }) // ========================================================================== - // Group 7: requestHandler full pipeline — exercise handler dispatch via message events (6 tests) + // Group 5: requestHandler full pipeline — exercise handler dispatch via message events (6 tests) // ========================================================================== await describe('requestHandler full pipeline OCPP 2.0.1', async () => { diff --git a/tests/charging-station/ocpp/auth/services/OCPPAuthServiceFactory.test.ts b/tests/charging-station/ocpp/auth/services/OCPPAuthServiceFactory.test.ts index c1ef1868..1090c4d2 100644 --- a/tests/charging-station/ocpp/auth/services/OCPPAuthServiceFactory.test.ts +++ b/tests/charging-station/ocpp/auth/services/OCPPAuthServiceFactory.test.ts @@ -58,8 +58,7 @@ await describe('OCPPAuthServiceFactory', async () => { try { await OCPPAuthServiceFactory.getInstance(mockStation) - // If we get here, the test should fail - assert.strictEqual(true, false) // Force failure + assert.fail('Expected getInstance to throw for station without stationInfo') } catch (error) { assert.ok(error instanceof Error) assert.ok(error.message.includes('OCPP version not found in charging station')) diff --git a/tests/charging-station/ocpp/auth/types/AuthTypes.test.ts b/tests/charging-station/ocpp/auth/types/AuthTypes.test.ts index 999afcdc..9ff15c61 100644 --- a/tests/charging-station/ocpp/auth/types/AuthTypes.test.ts +++ b/tests/charging-station/ocpp/auth/types/AuthTypes.test.ts @@ -8,7 +8,6 @@ import { afterEach, describe, it } from 'node:test' import { AuthContext, AuthenticationError, - AuthenticationMethod, AuthErrorCode, AuthorizationStatus, IdentifierType, @@ -298,39 +297,4 @@ await describe('AuthTypes', async () => { assert.strictEqual(identifier.certificateHashData?.hashAlgorithm, 'SHA256') }) }) - - await describe('Enums', async () => { - await it('should have correct AuthContext values', () => { - assert.strictEqual(AuthContext.TRANSACTION_START, 'TransactionStart') - assert.strictEqual(AuthContext.TRANSACTION_STOP, 'TransactionStop') - assert.strictEqual(AuthContext.REMOTE_START, 'RemoteStart') - assert.strictEqual(AuthContext.REMOTE_STOP, 'RemoteStop') - assert.strictEqual(AuthContext.RESERVATION, 'Reservation') - assert.strictEqual(AuthContext.UNLOCK_CONNECTOR, 'UnlockConnector') - }) - - await it('should have correct AuthenticationMethod values', () => { - assert.strictEqual(AuthenticationMethod.LOCAL_LIST, 'LocalList') - assert.strictEqual(AuthenticationMethod.REMOTE_AUTHORIZATION, 'RemoteAuthorization') - assert.strictEqual(AuthenticationMethod.CACHE, 'Cache') - assert.strictEqual(AuthenticationMethod.CERTIFICATE_BASED, 'CertificateBased') - assert.strictEqual(AuthenticationMethod.OFFLINE_FALLBACK, 'OfflineFallback') - }) - - await it('should have correct AuthorizationStatus values', () => { - assert.strictEqual(AuthorizationStatus.ACCEPTED, 'Accepted') - assert.strictEqual(AuthorizationStatus.BLOCKED, 'Blocked') - assert.strictEqual(AuthorizationStatus.EXPIRED, 'Expired') - assert.strictEqual(AuthorizationStatus.INVALID, 'Invalid') - assert.strictEqual(AuthorizationStatus.CONCURRENT_TX, 'ConcurrentTx') - }) - - await it('should have correct IdentifierType values', () => { - assert.strictEqual(IdentifierType.ID_TAG, 'IdTag') - assert.strictEqual(IdentifierType.CENTRAL, 'Central') - assert.strictEqual(IdentifierType.LOCAL, 'Local') - assert.strictEqual(IdentifierType.E_MAID, 'eMAID') - assert.strictEqual(IdentifierType.KEY_CODE, 'KeyCode') - }) - }) }) diff --git a/tests/types/ConfigurationData.test.ts b/tests/types/ConfigurationData.test.ts deleted file mode 100644 index 81d9d6ca..00000000 --- a/tests/types/ConfigurationData.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @file Tests for ConfigurationData - * @description Unit tests for configuration data types and enumerations - */ -import assert from 'node:assert/strict' -import { afterEach, describe, it } from 'node:test' - -import { - ApplicationProtocolVersion, - ConfigurationSection, - SupervisionUrlDistribution, -} from '../../src/types/ConfigurationData.js' -import { standardCleanup } from '../helpers/TestLifecycleHelpers.js' - -await describe('ConfigurationData', async () => { - afterEach(() => { - standardCleanup() - }) - - await it('should define ConfigurationSection enumeration values', () => { - assert.strictEqual(ConfigurationSection.log, 'log') - assert.strictEqual(ConfigurationSection.performanceStorage, 'performanceStorage') - assert.strictEqual(ConfigurationSection.uiServer, 'uiServer') - assert.strictEqual(ConfigurationSection.worker, 'worker') - }) - - await it('should define SupervisionUrlDistribution enumeration values', () => { - assert.strictEqual( - SupervisionUrlDistribution.CHARGING_STATION_AFFINITY, - 'charging-station-affinity' - ) - assert.strictEqual(SupervisionUrlDistribution.RANDOM, 'random') - assert.strictEqual(SupervisionUrlDistribution.ROUND_ROBIN, 'round-robin') - }) - - await it('should define ApplicationProtocolVersion enumeration values', () => { - assert.strictEqual(ApplicationProtocolVersion.VERSION_11, '1.1') - assert.strictEqual(ApplicationProtocolVersion.VERSION_20, '2.0') - }) -}) diff --git a/tests/utils/ChargingStationConfigurationUtils.test.ts b/tests/utils/ChargingStationConfigurationUtils.test.ts index 3168b7ed..961d20fd 100644 --- a/tests/utils/ChargingStationConfigurationUtils.test.ts +++ b/tests/utils/ChargingStationConfigurationUtils.test.ts @@ -48,13 +48,6 @@ await describe('ChargingStationConfigurationUtils', async () => { standardCleanup() }) - await describe('OutputFormat', async () => { - await it('should have correct enum values', () => { - assert.strictEqual(OutputFormat.configuration, 'configuration') - assert.strictEqual(OutputFormat.worker, 'worker') - }) - }) - await describe('buildConnectorsStatus', async () => { await it('should strip internal transaction fields from connectors', () => { const noop = (): void => {