From 351cccce0ed2855b760c190b638aa19421e6d9d7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 18 Mar 2026 21:07:13 +0100 Subject: [PATCH] test: move truncateId tests from InMemoryAuthCache to Utils truncateId is a general utility function in src/utils/, not a cache feature. Its tests belong in the utils test file. --- .../ocpp/auth/cache/InMemoryAuthCache.test.ts | 13 ------------- tests/utils/Utils.test.ts | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/charging-station/ocpp/auth/cache/InMemoryAuthCache.test.ts b/tests/charging-station/ocpp/auth/cache/InMemoryAuthCache.test.ts index c490e184..706db7a1 100644 --- a/tests/charging-station/ocpp/auth/cache/InMemoryAuthCache.test.ts +++ b/tests/charging-station/ocpp/auth/cache/InMemoryAuthCache.test.ts @@ -12,7 +12,6 @@ import { AuthenticationMethod, AuthorizationStatus, } from '../../../../../src/charging-station/ocpp/auth/types/AuthTypes.js' -import { truncateId } from '../../../../../src/utils/index.js' import { standardCleanup, withMockTimers } from '../../../../helpers/TestLifecycleHelpers.js' import { createMockAuthorizationResult } from '../helpers/MockFactories.js' @@ -731,18 +730,6 @@ await describe('InMemoryAuthCache - G03.FR.01 Conformance', async () => { }) }) - await describe('Helper - truncateId', async () => { - await it('should return identifier unchanged when short', () => { - const result = truncateId('ABCD') - assert.strictEqual(result, 'ABCD') - }) - - await it('should truncate long identifier with ellipsis', () => { - const result = truncateId('ABCDEFGHIJKLMNOP') - assert.strictEqual(result, 'ABCDEFGH...') - }) - }) - await describe('G03.FR.01.T10 - Periodic Cleanup and Rate Limit Bounds (R8, R9)', async () => { await it('G03.FR.01.T10.01 - dispose() stops the cleanup interval and is safe to call twice', () => { const cleanupCache = new InMemoryAuthCache({ diff --git a/tests/utils/Utils.test.ts b/tests/utils/Utils.test.ts index 87e6daca..38cc4778 100644 --- a/tests/utils/Utils.test.ts +++ b/tests/utils/Utils.test.ts @@ -51,6 +51,7 @@ import { roundTo, secureRandom, sleep, + truncateId, validateIdentifierString, validateUUID, } from '../../src/utils/Utils.js' @@ -814,4 +815,16 @@ await describe('Utils', async () => { callback() }, error) }) + + await describe('truncateId', async () => { + await it('should return identifier unchanged when short', () => { + const result = truncateId('ABCD') + assert.strictEqual(result, 'ABCD') + }) + + await it('should truncate long identifier with ellipsis', () => { + const result = truncateId('ABCDEFGHIJKLMNOP') + assert.strictEqual(result, 'ABCDEFGH...') + }) + }) }) -- 2.53.0