/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { expect } from '@std/expect'
-import { describe, it } from 'node:test'
+import { afterEach, describe, it } from 'node:test'
import {
addConfigurationKey,
const incomingRequestService = new OCPP20IncomingRequestService()
+ // Reset singleton state after each test to ensure test isolation
+ afterEach(() => {
+ OCPP20VariableManager.getInstance().resetRuntimeOverrides()
+ })
+
// FR: B07.FR.01, B07.FR.07
await it('Should handle GetBaseReport request with ConfigurationInventory', () => {
const request: OCPP20GetBaseReportRequest = {
*/
import { expect } from '@std/expect'
import { millisecondsToSeconds } from 'date-fns'
-import { describe, it } from 'node:test'
+import { afterEach, describe, it } from 'node:test'
import { OCPP20IncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.js'
+import { OCPP20VariableManager } from '../../../../src/charging-station/ocpp/2.0/OCPP20VariableManager.js'
import {
AttributeEnumType,
GetVariableStatusEnumType,
const incomingRequestService = new OCPP20IncomingRequestService()
+ // Reset singleton state after each test to ensure test isolation
+ afterEach(() => {
+ OCPP20VariableManager.getInstance().resetRuntimeOverrides()
+ })
+
// FR: B06.FR.01
await it('Should handle GetVariables request with valid variables', () => {
const request: OCPP20GetVariablesRequest = {
import { expect } from '@std/expect'
import { millisecondsToSeconds } from 'date-fns'
-import { describe, it } from 'node:test'
+import { afterEach, describe, it } from 'node:test'
import { OCPP20IncomingRequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.js'
+import { OCPP20VariableManager } from '../../../../src/charging-station/ocpp/2.0/OCPP20VariableManager.js'
import {
AttributeEnumType,
GetVariableStatusEnumType,
const incomingRequestService = new OCPP20IncomingRequestService()
const svc = incomingRequestService as unknown as IncomingRequestServicePrivate
+ // Reset singleton state after each test to ensure test isolation
+ afterEach(() => {
+ OCPP20VariableManager.getInstance().resetRuntimeOverrides()
+ })
+
// FR: B05.FR.01, B05.FR.10
await it('Should handle SetVariables request with valid writable variables', () => {
const request: OCPP20SetVariablesRequest = {
import { expect } from '@std/expect'
import { millisecondsToSeconds } from 'date-fns'
-import { describe, it } from 'node:test'
+import { afterEach, describe, it } from 'node:test'
import {
deleteConfigurationKey,
websocketPingInterval: Constants.DEFAULT_WEBSOCKET_PING_INTERVAL,
})
+ // Reset singleton state after each test to ensure test isolation
+ afterEach(() => {
+ OCPP20VariableManager.getInstance().resetRuntimeOverrides()
+ })
+
await it('Verify that OCPP20VariableManager can be instantiated as singleton', () => {
const manager1 = OCPP20VariableManager.getInstance()
const manager2 = OCPP20VariableManager.getInstance()
* @description Unit tests for OCPP authentication service factory
*/
import { expect } from '@std/expect'
-import { describe, it } from 'node:test'
+import { afterEach, describe, it } from 'node:test'
import type { ChargingStation } from '../../../../../src/charging-station/ChargingStation.js'
import { createMockAuthServiceTestStation } from '../helpers/MockFactories.js'
await describe('OCPPAuthServiceFactory', async () => {
+ // Clear all cached instances after each test to ensure test isolation
+ afterEach(() => {
+ OCPPAuthServiceFactory.clearAllInstances()
+ })
+
await describe('getInstance', async () => {
await it('should create a new instance for a charging station', async () => {
const mockStation = createMockAuthServiceTestStation('001')