From 243a494b9598b7aa85f9b5cdca067cd5fd4f5b06 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 26 Jul 2024 18:52:31 +0200 Subject: [PATCH] test: add checkConfiguration() helper test MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- tests/charging-station/Helpers.test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/charging-station/Helpers.test.ts b/tests/charging-station/Helpers.test.ts index 865d595f..85e66adb 100644 --- a/tests/charging-station/Helpers.test.ts +++ b/tests/charging-station/Helpers.test.ts @@ -5,6 +5,7 @@ import { expect } from 'expect' import { checkChargingStationState, + checkConfiguration, checkTemplate, getChargingStationId, getHashId, @@ -14,6 +15,7 @@ import { import type { ChargingStation } from '../../src/charging-station/index.js' import { BaseError } from '../../src/exception/index.js' import { + type ChargingStationConfiguration, type ChargingStationInfo, type ChargingStationTemplate, type ConnectorStatus, @@ -163,4 +165,18 @@ await describe('Helpers test suite', async () => { checkTemplate(chargingStationTemplate, 'log prefix |', 'test-template.json') expect(logger.warn.mock.calls.length).toBe(1) }) + + await it('Verify checkConfiguration()', t => { + t.mock.method(logger, 'error') + expect(() => { + checkConfiguration(undefined, 'log prefix |', 'configuration.json') + }).toThrow( + new BaseError('Failed to read charging station configuration file configuration.json') + ) + expect(logger.error.mock.calls.length).toBe(1) + expect(() => { + checkConfiguration({} as ChargingStationConfiguration, 'log prefix |', 'configuration.json') + }).toThrow(new BaseError('Empty charging station configuration from file configuration.json')) + expect(logger.error.mock.calls.length).toBe(2) + }) }) -- 2.34.1