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
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)
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)
})
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
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)
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,
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')
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,
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(
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(
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, {
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')
})
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)
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
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')
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)
})
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
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')
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')
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(), {
})
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)