]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix(tests): rename test cases to 'should [verb]' convention
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 3 Mar 2026 17:47:56 +0000 (18:47 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 3 Mar 2026 17:47:56 +0000 (18:47 +0100)
Rename 17 test names across 3 files to follow
TEST_STYLE_GUIDE.md naming convention.

tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-TriggerMessage.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-UnlockConnector.test.ts
tests/charging-station/ocpp/2.0/OCPP20SchemaValidation.test.ts

index 4cb765e5c86ee16f540acc311295deab96fc56ce..3a2d8ce360568f1f03f0e28576d9076e1db56da9 100644 (file)
@@ -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,
       }
index 5c39e73630c765d914d209ae0bf43024252c76dd..900ba4f4bf327856e6951bf67d3f3ed9ada60219 100644 (file)
@@ -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 }
index 35388ee8b9fb005cf6afd19d4c304868d49f2a09..7b25153f662c7a6ad806ba0ee34d1de374be26e2 100644 (file)
@@ -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)