]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor(tests): standardize test naming to BDD style
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 27 Feb 2026 16:32:17 +0000 (17:32 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 27 Feb 2026 16:32:17 +0000 (17:32 +0100)
tests/charging-station/ConfigurationKeyUtils.test.ts
tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts

index c7104fd4bc242f02b6809e4e8608e52cceed191e..f15720993396c91c649d861e98e53f87edb5ba3c 100644 (file)
@@ -17,7 +17,7 @@ const VALUE_B = 'ValueB'
 
 await describe('ConfigurationKeyUtils test suite', async () => {
   await describe('getConfigurationKey()', async () => {
-    await it('returns undefined when configurationKey array is missing', () => {
+    await it('should return undefined when configurationKey array is missing', () => {
       const cs = createChargingStation()
       // remove array
       // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
@@ -25,7 +25,7 @@ await describe('ConfigurationKeyUtils test suite', async () => {
       expect(getConfigurationKey(cs, TEST_KEY_1)).toBeUndefined()
     })
 
-    await it('finds existing key (case-sensitive)', () => {
+    await it('should find existing key (case-sensitive)', () => {
       const cs = createChargingStation()
       addConfigurationKey(cs, TEST_KEY_1, VALUE_A, undefined, { save: false })
       const k = getConfigurationKey(cs, TEST_KEY_1)
@@ -33,13 +33,13 @@ await describe('ConfigurationKeyUtils test suite', async () => {
       expect(k?.value).toBe(VALUE_A)
     })
 
-    await it('respects case sensitivity (no match)', () => {
+    await it('should respect case sensitivity (no match)', () => {
       const cs = createChargingStation()
       addConfigurationKey(cs, MIXED_CASE_KEY, VALUE_A, undefined, { save: false })
       expect(getConfigurationKey(cs, MIXED_CASE_KEY.toLowerCase())).toBeUndefined()
     })
 
-    await it('supports caseInsensitive lookup', () => {
+    await it('should support caseInsensitive lookup', () => {
       const cs = createChargingStation()
       addConfigurationKey(cs, MIXED_CASE_KEY, VALUE_A, undefined, { save: false })
       const k = getConfigurationKey(cs, MIXED_CASE_KEY.toLowerCase(), true)
@@ -48,7 +48,7 @@ await describe('ConfigurationKeyUtils test suite', async () => {
   })
 
   await describe('addConfigurationKey()', async () => {
-    await it('no-op when configurationKey array missing', () => {
+    await it('should no-op when configurationKey array missing', () => {
       const cs = createChargingStation()
       // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
       cs.ocppConfiguration = {} as any
@@ -56,7 +56,7 @@ await describe('ConfigurationKeyUtils test suite', async () => {
       expect(getConfigurationKey(cs, TEST_KEY_1)).toBeUndefined()
     })
 
-    await it('adds new key with default options', () => {
+    await it('should add new key with default options', () => {
       const cs = createChargingStation()
       addConfigurationKey(cs, TEST_KEY_1, VALUE_A, undefined, { save: false })
       const k = getConfigurationKey(cs, TEST_KEY_1)
@@ -68,7 +68,7 @@ await describe('ConfigurationKeyUtils test suite', async () => {
       expect(k?.visible).toBe(true)
     })
 
-    await it('adds new key with custom options', () => {
+    await it('should add new key with custom options', () => {
       const cs = createChargingStation()
       addConfigurationKey(
         cs,
@@ -83,7 +83,7 @@ await describe('ConfigurationKeyUtils test suite', async () => {
       expect(k?.visible).toBe(false)
     })
 
-    await it('logs error and does not overwrite value when key exists and overwrite=false', t => {
+    await it('should log error and not overwrite value when key exists and overwrite=false', t => {
       const cs = createChargingStation()
       addConfigurationKey(cs, TEST_KEY_1, VALUE_A, { readonly: false }, { save: false })
       const errorMock = t.mock.method(logger, 'error')
@@ -105,7 +105,7 @@ await describe('ConfigurationKeyUtils test suite', async () => {
       expect(errorMock.mock.calls.length).toBe(1)
     })
 
-    await it('logs error and leaves key untouched when identical options & value attempted (overwrite=false)', t => {
+    await it('should log error and leave key untouched when identical options & value attempted (overwrite=false)', t => {
       const cs = createChargingStation()
       addConfigurationKey(
         cs,
@@ -131,7 +131,7 @@ await describe('ConfigurationKeyUtils test suite', async () => {
       expect(errorMock.mock.calls.length).toBe(1)
     })
 
-    await it('overwrites existing key value and options when overwrite=true', () => {
+    await it('should overwrite existing key value and options when overwrite=true', () => {
       const cs = createChargingStation()
       addConfigurationKey(cs, TEST_KEY_1, VALUE_A, { readonly: false }, { save: false })
       addConfigurationKey(
@@ -148,7 +148,7 @@ await describe('ConfigurationKeyUtils test suite', async () => {
       expect(k?.visible).toBe(false)
     })
 
-    await it('caseInsensitive overwrite updates existing differently cased key', () => {
+    await it('should caseInsensitive overwrite update existing differently cased key', () => {
       const cs = createChargingStation()
       addConfigurationKey(cs, MIXED_CASE_KEY, VALUE_A, undefined, { save: false })
       addConfigurationKey(
@@ -163,7 +163,7 @@ await describe('ConfigurationKeyUtils test suite', async () => {
       expect(k?.readonly).toBe(true)
     })
 
-    await it('case-insensitive false creates separate key with different case', () => {
+    await it('should case-insensitive false create separate key with different case', () => {
       const cs = createChargingStation()
       addConfigurationKey(cs, MIXED_CASE_KEY, VALUE_A, undefined, { save: false })
       addConfigurationKey(cs, MIXED_CASE_KEY.toLowerCase(), VALUE_B, undefined, {
@@ -177,14 +177,14 @@ await describe('ConfigurationKeyUtils test suite', async () => {
       expect(orig).not.toBe(second)
     })
 
-    await it('calls saveOcppConfiguration when params.save=true (new key)', t => {
+    await it('should call saveOcppConfiguration when params.save=true (new key)', t => {
       const cs = createChargingStation()
       const saveMock = t.mock.method(cs, 'saveOcppConfiguration')
       addConfigurationKey(cs, TEST_KEY_1, VALUE_A, undefined, { save: true })
       expect(saveMock.mock.calls.length).toBe(1)
     })
 
-    await it('calls saveOcppConfiguration when overwriting existing key and save=true', t => {
+    await it('should call saveOcppConfiguration when overwriting existing key and save=true', t => {
       const cs = createChargingStation()
       addConfigurationKey(cs, TEST_KEY_1, VALUE_A, undefined, { save: false })
       const saveMock = t.mock.method(cs, 'saveOcppConfiguration')
@@ -200,7 +200,7 @@ await describe('ConfigurationKeyUtils test suite', async () => {
   })
 
   await describe('setConfigurationKeyValue()', async () => {
-    await it('returns undefined and logs error for non-existing key', t => {
+    await it('should return undefined and log error for non-existing key', t => {
       const cs = createChargingStation()
       const errorMock = t.mock.method(logger, 'error')
       const res = setConfigurationKeyValue(cs, TEST_KEY_1, VALUE_A)
@@ -208,7 +208,7 @@ await describe('ConfigurationKeyUtils test suite', async () => {
       expect(errorMock.mock.calls.length).toBe(1)
     })
 
-    await it('returns undefined without logging when configurationKey array missing', t => {
+    await it('should return undefined without logging when configurationKey array missing', t => {
       const cs = createChargingStation()
       // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
       cs.ocppConfiguration = {} as any
@@ -218,7 +218,7 @@ await describe('ConfigurationKeyUtils test suite', async () => {
       expect(errorMock.mock.calls.length).toBe(0)
     })
 
-    await it('updates existing key value and saves', t => {
+    await it('should update existing key value and save', t => {
       const cs = createChargingStation()
       addConfigurationKey(cs, TEST_KEY_1, VALUE_A, undefined, { save: false })
       const saveMock = t.mock.method(cs, 'saveOcppConfiguration')
@@ -227,7 +227,7 @@ await describe('ConfigurationKeyUtils test suite', async () => {
       expect(saveMock.mock.calls.length).toBe(1)
     })
 
-    await it('caseInsensitive value update works', () => {
+    await it('should caseInsensitive value update work', () => {
       const cs = createChargingStation()
       addConfigurationKey(cs, MIXED_CASE_KEY, VALUE_A, undefined, { save: false })
       const updated = setConfigurationKeyValue(cs, MIXED_CASE_KEY.toLowerCase(), VALUE_B, true)
@@ -236,7 +236,7 @@ await describe('ConfigurationKeyUtils test suite', async () => {
   })
 
   await describe('deleteConfigurationKey()', async () => {
-    await it('returns undefined when configurationKey array missing', () => {
+    await it('should return undefined when configurationKey array missing', () => {
       const cs = createChargingStation()
       // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
       cs.ocppConfiguration = {} as any
@@ -244,13 +244,13 @@ await describe('ConfigurationKeyUtils test suite', async () => {
       expect(res).toBeUndefined()
     })
 
-    await it('returns undefined when key does not exist', () => {
+    await it('should return undefined when key does not exist', () => {
       const cs = createChargingStation()
       const res = deleteConfigurationKey(cs, TEST_KEY_1)
       expect(res).toBeUndefined()
     })
 
-    await it('deletes existing key and saves by default', t => {
+    await it('should delete existing key and save by default', t => {
       const cs = createChargingStation()
       addConfigurationKey(cs, TEST_KEY_1, VALUE_A, undefined, { save: false })
       const saveMock = t.mock.method(cs, 'saveOcppConfiguration')
@@ -262,7 +262,7 @@ await describe('ConfigurationKeyUtils test suite', async () => {
       expect(saveMock.mock.calls.length).toBe(1)
     })
 
-    await it('does not save when params.save=false', t => {
+    await it('should not save when params.save=false', t => {
       const cs = createChargingStation()
       addConfigurationKey(cs, TEST_KEY_1, VALUE_A, undefined, { save: false })
       const saveMock = t.mock.method(cs, 'saveOcppConfiguration')
@@ -271,7 +271,7 @@ await describe('ConfigurationKeyUtils test suite', async () => {
       expect(saveMock.mock.calls.length).toBe(0)
     })
 
-    await it('caseInsensitive deletion removes key with different case', () => {
+    await it('should caseInsensitive deletion remove key with different case', () => {
       const cs = createChargingStation()
       addConfigurationKey(cs, MIXED_CASE_KEY, VALUE_A, undefined, { save: false })
       const deleted = deleteConfigurationKey(cs, MIXED_CASE_KEY.toLowerCase(), {
@@ -284,7 +284,7 @@ await describe('ConfigurationKeyUtils test suite', async () => {
   })
 
   await describe('Combined scenarios', async () => {
-    await it('add then set then delete lifecycle', () => {
+    await it('should add then set then delete lifecycle', () => {
       const cs = createChargingStation()
       addConfigurationKey(cs, TEST_KEY_1, VALUE_A, { readonly: false }, { save: false })
       const setRes = setConfigurationKeyValue(cs, TEST_KEY_1, VALUE_B)
index bc3f9541401215089942ff1733e1c8a82523aae4..da53b9a73531f149d6758f7aeee2862698f9f05f 100644 (file)
@@ -1386,7 +1386,7 @@ await describe('B05/B06 - OCPP20VariableManager test suite', async () => {
       websocketPingInterval: Constants.DEFAULT_WEBSOCKET_PING_INTERVAL,
     })
 
-    await it('Returns NotSupportedAttributeType for MinSet HeartbeatInterval', () => {
+    await it('should return NotSupportedAttributeType for MinSet HeartbeatInterval', () => {
       const component = { name: OCPP20ComponentName.OCPPCommCtrlr }
       const variable = { name: OCPP20OptionalVariableName.HeartbeatInterval }
       const res = manager.getVariables(station, [
@@ -1396,7 +1396,7 @@ await describe('B05/B06 - OCPP20VariableManager test suite', async () => {
       expect(res.attributeStatusInfo?.reasonCode).toBe(ReasonCodeEnumType.UnsupportedParam)
     })
 
-    await it('Returns NotSupportedAttributeType for MaxSet WebSocketPingInterval', () => {
+    await it('should return NotSupportedAttributeType for MaxSet WebSocketPingInterval', () => {
       const component = { name: OCPP20ComponentName.ChargingStation }
       const variable = { name: OCPP20OptionalVariableName.WebSocketPingInterval }
       const res = manager.getVariables(station, [