export const TEST_HEARTBEAT_INTERVAL_SECONDS = 60
export const TEST_HEARTBEAT_INTERVAL_MS = 30000
export const TEST_AUTHORIZATION_TIMEOUT_MS = 30000
-export const TEST_ONE_HOUR_MS = 3600000
+export const TEST_ONE_HOUR_SECONDS = 3600
+export const TEST_ONE_HOUR_MS = TEST_ONE_HOUR_SECONDS * 1000
/**
* Charging Station Information
export const TEST_TOKEN_ISO14443 = 'TEST_RFID_TOKEN_001'
export const TEST_TOKEN_EMAID = 'DE*ABC*E123456*1'
export const TEST_TOKEN_CENTRAL = 'CENTRAL_TOKEN_001'
+
+/**
+ * Cache Configuration Constants
+ * Test values for cache-related timing and limits
+ */
+export const TEST_CACHE_TTL_SECONDS = TEST_ONE_HOUR_SECONDS
+export const TEST_MAX_CACHE_ENTRIES = 1000
+
+/**
+ * Rate Limiting Constants
+ * Test values for rate limiting windows and intervals
+ */
+export const TEST_RATE_LIMIT_WINDOW_MS = 1000
+
+/**
+ * Custom Interval Constants
+ * Test values for custom heartbeat and timeout intervals
+ */
+export const TEST_CUSTOM_HEARTBEAT_INTERVAL_SECONDS = 120
+export const TEST_REJECTED_HEARTBEAT_INTERVAL_SECONDS = TEST_ONE_HOUR_SECONDS
+
+/**
+ * OCPP 2.0 Value Size Limits
+ * Test values for variable value size constraints
+ */
+export const TEST_VALUE_SIZE_LIMIT = 120
+export const TEST_CONFIGURATION_VALUE_SIZE = 60
-// Copyright Jerome Benoit. 2021-2025. All Rights Reserved.
-
+/**
+ * @file MockFactories
+ * @description Mock factory functions for authentication testing
+ */
import { expect } from '@std/expect'
import type { ChargingStation } from '../../../../../src/charging-station/ChargingStation.js'
* @file Tests for AuthConfigValidator
* @description Unit tests for authentication configuration validation
*/
-// Copyright Jerome Benoit. 2021-2025. All Rights Reserved.
import { expect } from '@std/expect'
import { afterEach, describe, it } from 'node:test'
* @file Tests for UIHttpServer
* @description Unit tests for HTTP-based UI server and response handling
*/
-// Copyright Jerome Benoit. 2024-2025. All Rights Reserved.
import { expect } from '@std/expect'
import { afterEach, beforeEach, describe, it } from 'node:test'
-// Copyright Jerome Benoit. 2024-2025. All Rights Reserved.
+/**
+ * @file UI Server test constants
+ * @description Common constants for UI server test suites (WebSocket, HTTP)
+ */
import type { UUIDv4 } from '../../../src/types/index.js'
-// Copyright Jerome Benoit. 2024-2025. All Rights Reserved.
-
+/**
+ * @file UIServerTestUtils
+ * @description Test utilities for UI server testing
+ */
import type { IncomingMessage } from 'node:http'
import { EventEmitter } from 'node:events'
* @file Tests for AbstractUIService
* @description Unit tests for abstract UI service base class functionality
*/
-// Copyright Jerome Benoit. 2024-2025. All Rights Reserved.
import { expect } from '@std/expect'
import { afterEach, describe, it } from 'node:test'
afterEach(() => {
standardCleanup()
})
- await it('should run synchronous functions exclusively in sequence', () => {
+ await it('should run synchronous functions exclusively in sequence', async () => {
const runs = 10
const executed: number[] = []
let count = 0
const fn = () => {
executed.push(++count)
}
+
+ const promises: Promise<void>[] = []
for (let i = 0; i < runs; i++) {
- AsyncLock.runExclusive(AsyncLockType.configuration, fn)
- .then(() => {
- expect(executed).toStrictEqual(new Array(count).fill(0).map((_, i) => ++i))
- return undefined
- })
- .catch(console.error)
+ promises.push(AsyncLock.runExclusive(AsyncLockType.configuration, fn))
}
+ await Promise.all(promises)
+ expect(executed).toStrictEqual(new Array(runs).fill(0).map((_, i) => ++i))
})
- await it('should run asynchronous functions exclusively in sequence', () => {
+ await it('should run asynchronous functions exclusively in sequence', async () => {
const runs = 10
const executed: number[] = []
let count = 0
})
executed.push(++count)
}
+
+ const promises: Promise<void>[] = []
for (let i = 0; i < runs; i++) {
- AsyncLock.runExclusive(AsyncLockType.configuration, asyncFn)
- .then(() => {
- expect(executed).toStrictEqual(new Array(count).fill(0).map((_, i) => ++i))
- return undefined
- })
- .catch(console.error)
+ promises.push(AsyncLock.runExclusive(AsyncLockType.configuration, asyncFn))
}
+ await Promise.all(promises)
+ expect(executed).toStrictEqual(new Array(runs).fill(0).map((_, i) => ++i))
})
})