From e523ff4e59e50371ddae16e009d60b015a113113 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 3 Mar 2026 18:47:56 +0100 Subject: [PATCH] fix(tests): rename test cases to 'should [verb]' convention Rename 17 test names across 3 files to follow TEST_STYLE_GUIDE.md naming convention. --- ...omingRequestService-TriggerMessage.test.ts | 2 +- ...mingRequestService-UnlockConnector.test.ts | 2 +- .../ocpp/2.0/OCPP20SchemaValidation.test.ts | 30 +++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-TriggerMessage.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-TriggerMessage.test.ts index 4cb765e5..3a2d8ce3 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-TriggerMessage.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-TriggerMessage.test.ts @@ -345,7 +345,7 @@ await describe('F06 - TriggerMessage', async () => { expect(typeof response.status).toBe('string') }) - await it('handler is synchronous — result is not a Promise', () => { + await it('should not return a Promise from synchronous handler', () => { const request: OCPP20TriggerMessageRequest = { requestedMessage: MessageTriggerEnumType.BootNotification, } diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-UnlockConnector.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-UnlockConnector.test.ts index 5c39e736..900ba4f4 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-UnlockConnector.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-UnlockConnector.test.ts @@ -191,7 +191,7 @@ await describe('F05 - UnlockConnector', async () => { expect(requestHandlerMock.mock.calls.length).toBeGreaterThan(0) }) - await it('handler is async — result is a Promise', async () => { + await it('should return a Promise from async handler', async () => { const { mockStation } = createUnlockConnectorStation() const request: OCPP20UnlockConnectorRequest = { connectorId: 1, evseId: 1 } diff --git a/tests/charging-station/ocpp/2.0/OCPP20SchemaValidation.test.ts b/tests/charging-station/ocpp/2.0/OCPP20SchemaValidation.test.ts index 35388ee8..7b25153f 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20SchemaValidation.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20SchemaValidation.test.ts @@ -55,17 +55,17 @@ await describe('OCPP 2.0 schema validation — negative tests', async () => { standardCleanup() }) - await it('AJV compiles ResetRequest schema without error (strict:false required)', () => { + await it('should compile ResetRequest schema without error (strict:false required)', () => { // Verifies the AJV configuration works for schemas using additionalItems pattern expect(() => makeValidator('ResetRequest.json')).not.toThrow() }) - await it('AJV compiles GetVariablesRequest schema without error (uses additionalItems)', () => { + await it('should compile GetVariablesRequest schema without error (uses additionalItems)', () => { // GetVariablesRequest uses additionalItems:false — would fail in strict mode expect(() => makeValidator('GetVariablesRequest.json')).not.toThrow() }) - await it('Reset: missing required "type" field → validation fails', () => { + await it('should fail validation when Reset payload is missing required "type" field', () => { const validate = makeValidator('ResetRequest.json') expect(validate({})).toBe(false) expect(validate.errors).toBeDefined() @@ -78,7 +78,7 @@ await describe('OCPP 2.0 schema validation — negative tests', async () => { expect(hasMissingType).toBe(true) }) - await it('Reset: invalid "type" enum value → validation fails', () => { + await it('should fail validation when Reset payload has invalid "type" enum value', () => { const validate = makeValidator('ResetRequest.json') // Valid values are Immediate and OnIdle only; HardReset is OCPP 1.6 expect(validate({ type: 'HardReset' })).toBe(false) @@ -87,7 +87,7 @@ await describe('OCPP 2.0 schema validation — negative tests', async () => { expect(hasEnumError).toBe(true) }) - await it('GetVariables: empty getVariableData array (minItems:1) → validation fails', () => { + await it('should fail validation when GetVariables has empty getVariableData array', () => { const validate = makeValidator('GetVariablesRequest.json') expect(validate({ getVariableData: [] })).toBe(false) expect(validate.errors).toBeDefined() @@ -95,7 +95,7 @@ await describe('OCPP 2.0 schema validation — negative tests', async () => { expect(hasMinItemsError).toBe(true) }) - await it('GetVariables: missing required getVariableData → validation fails', () => { + await it('should fail validation when GetVariables is missing required getVariableData', () => { const validate = makeValidator('GetVariablesRequest.json') expect(validate({})).toBe(false) expect(validate.errors).toBeDefined() @@ -107,7 +107,7 @@ await describe('OCPP 2.0 schema validation — negative tests', async () => { expect(hasMissingProp).toBe(true) }) - await it('SetVariables: missing required setVariableData → validation fails', () => { + await it('should fail validation when SetVariables is missing required setVariableData', () => { const validate = makeValidator('SetVariablesRequest.json') expect(validate({})).toBe(false) expect(validate.errors).toBeDefined() @@ -119,7 +119,7 @@ await describe('OCPP 2.0 schema validation — negative tests', async () => { expect(hasMissingProp).toBe(true) }) - await it('TriggerMessage: invalid requestedMessage enum value → validation fails', () => { + await it('should fail validation when TriggerMessage has invalid requestedMessage enum value', () => { const validate = makeValidator('TriggerMessageRequest.json') expect(validate({ requestedMessage: 'INVALID_MESSAGE_TYPE_XYZ' })).toBe(false) expect(validate.errors).toBeDefined() @@ -127,7 +127,7 @@ await describe('OCPP 2.0 schema validation — negative tests', async () => { expect(hasEnumError).toBe(true) }) - await it('TriggerMessage: missing required requestedMessage → validation fails', () => { + await it('should fail validation when TriggerMessage is missing required requestedMessage', () => { const validate = makeValidator('TriggerMessageRequest.json') expect(validate({})).toBe(false) expect(validate.errors).toBeDefined() @@ -139,7 +139,7 @@ await describe('OCPP 2.0 schema validation — negative tests', async () => { expect(hasMissingProp).toBe(true) }) - await it('UnlockConnector: missing required "evseId" → validation fails', () => { + await it('should fail validation when UnlockConnector is missing required evseId', () => { const validate = makeValidator('UnlockConnectorRequest.json') expect(validate({ connectorId: 1 })).toBe(false) expect(validate.errors).toBeDefined() @@ -151,7 +151,7 @@ await describe('OCPP 2.0 schema validation — negative tests', async () => { expect(hasMissingProp).toBe(true) }) - await it('UnlockConnector: missing required "connectorId" → validation fails', () => { + await it('should fail validation when UnlockConnector is missing required connectorId', () => { const validate = makeValidator('UnlockConnectorRequest.json') expect(validate({ evseId: 1 })).toBe(false) expect(validate.errors).toBeDefined() @@ -163,7 +163,7 @@ await describe('OCPP 2.0 schema validation — negative tests', async () => { expect(hasMissingProp).toBe(true) }) - await it('RequestStartTransaction: missing required "idToken" → validation fails', () => { + await it('should fail validation when RequestStartTransaction is missing required idToken', () => { const validate = makeValidator('RequestStartTransactionRequest.json') // remoteStartId is also required; provide it but omit idToken expect(validate({ remoteStartId: 1 })).toBe(false) @@ -176,7 +176,7 @@ await describe('OCPP 2.0 schema validation — negative tests', async () => { expect(hasMissingProp).toBe(true) }) - await it('CertificateSigned: missing required certificateChain → validation fails', () => { + await it('should fail validation when CertificateSigned is missing required certificateChain', () => { const validate = makeValidator('CertificateSignedRequest.json') expect(validate({})).toBe(false) expect(validate.errors).toBeDefined() @@ -188,14 +188,14 @@ await describe('OCPP 2.0 schema validation — negative tests', async () => { expect(hasMissingProp).toBe(true) }) - await it('Reset: valid payload passes validation', () => { + await it('should pass validation for valid Reset payloads', () => { const validate = makeValidator('ResetRequest.json') expect(validate({ type: 'Immediate' })).toBe(true) expect(validate({ type: 'OnIdle' })).toBe(true) expect(validate({ evseId: 1, type: 'OnIdle' })).toBe(true) }) - await it('TriggerMessage: valid payload passes validation', () => { + await it('should pass validation for valid TriggerMessage payloads', () => { const validate = makeValidator('TriggerMessageRequest.json') expect(validate({ requestedMessage: 'Heartbeat' })).toBe(true) expect(validate({ requestedMessage: 'BootNotification' })).toBe(true) -- 2.43.0