]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
test: move truncateId tests from InMemoryAuthCache to Utils
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 18 Mar 2026 20:07:13 +0000 (21:07 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 18 Mar 2026 20:07:13 +0000 (21:07 +0100)
truncateId is a general utility function in src/utils/, not a cache
feature. Its tests belong in the utils test file.

tests/charging-station/ocpp/auth/cache/InMemoryAuthCache.test.ts
tests/utils/Utils.test.ts

index c490e184bbdb3f7b7c03af2b61fcd8927cd939ad..706db7a1ff1f4247a9fc9f3b5125e7800082b01c 100644 (file)
@@ -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({
index 87e6dacaa363f6d6b41a5ec84b2510a960cca3a0..38cc477847dfff37e53324e3732aeb3a0f66c633 100644 (file)
@@ -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...')
+    })
+  })
 })