]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor: audit-driven quick wins — fix assert.ok misuse, naming conventions, and... main
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 24 Mar 2026 13:46:17 +0000 (14:46 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 24 Mar 2026 13:46:17 +0000 (14:46 +0100)
- Replace 71 improper assert.ok(comparison) with assert.strictEqual/notStrictEqual
  in 10 test files per TEST_STYLE_GUIDE (assert.ok for boolean/existence only)
- Rename lastUpdated → lastUpdatedDate in auth interfaces and strategies
  to follow Date suffix naming convention
- Extract hardcoded 'ws://localhost' to OCPP20Constants.DEFAULT_CONNECTION_URL
- Replace setTimeout(resolve, 50) with proper httpServer.close() await
  in UIMCPServer integration test

17 files changed:
src/charging-station/ocpp/2.0/OCPP20Constants.ts
src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts
src/charging-station/ocpp/auth/interfaces/OCPPAuthService.ts
src/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.ts
src/charging-station/ocpp/auth/strategies/LocalAuthStrategy.ts
src/charging-station/ocpp/auth/strategies/RemoteAuthStrategy.ts
tests/charging-station/ChargingStation-Configuration.test.ts
tests/charging-station/ChargingStation-Connectors.test.ts
tests/charging-station/ChargingStation-Resilience.test.ts
tests/charging-station/ChargingStation-Transactions.test.ts
tests/charging-station/ChargingStation.test.ts
tests/charging-station/ocpp/auth/helpers/MockFactories.ts
tests/charging-station/ui-server/UIMCPServer.integration.test.ts
tests/exception/BaseError.test.ts
tests/utils/ChargingStationConfigurationUtils.test.ts
tests/utils/Utils.test.ts
tests/worker/WorkerUtils.test.ts

index 64d6c60790d92743bed774fc67b93fe808f02754..c91d047a3bdd78e350d2e8a2e9a4050687662e8b 100644 (file)
@@ -138,6 +138,8 @@ export class OCPP20Constants extends OCPPConstants {
     // { from: OCPP20ConnectorStatusEnumType.Faulted, to: OCPP20ConnectorStatusEnumType.Faulted }
   ])
 
+  static readonly DEFAULT_CONNECTION_URL = 'ws://localhost'
+
   static readonly FIRMWARE_INSTALL_DELAY_MS = 5000
   static readonly FIRMWARE_STATUS_DELAY_MS = 2000
   static readonly FIRMWARE_VERIFY_DELAY_MS = 500
index c37be16aa85e460324fbced7974f1f3e16ed1c94..470ef54d06b9b00dd472980b33ead70b64c2be71 100644 (file)
@@ -20,6 +20,7 @@ import {
   type VariableName,
 } from '../../../types/index.js'
 import { Constants, convertToIntOrNaN, has } from '../../../utils/index.js'
+import { OCPP20Constants } from './OCPP20Constants.js'
 
 /**
  * Metadata describing a variable (component-level configuration or runtime state).
@@ -599,7 +600,7 @@ export const VARIABLE_REGISTRY: Record<string, VariableMetadata> = {
   )]: {
     component: OCPP20ComponentName.ChargingStation as string,
     dataType: DataEnumType.string,
-    defaultValue: 'ws://localhost',
+    defaultValue: OCPP20Constants.DEFAULT_CONNECTION_URL,
     description: 'Central system connection URL.',
     isUrl: true,
     maxLength: 512,
index d7b54acc9df5b52109fad916a68bda53e5825ea5..7122f981b46ae43e694c0c5dcf0af2d2df8f2d2d 100644 (file)
@@ -84,7 +84,7 @@ export interface AuthStats {
   failedAuth: number
 
   /** Last update timestamp */
-  lastUpdated: Date
+  lastUpdatedDate: Date
 
   /** Local authorization usage rate */
   localUsageRate: number
index 37286c0fa566c022d9ce85543634005e38ea7269..8420bc36365a167736f57e1b1752ef8092aa5870 100644 (file)
@@ -391,7 +391,7 @@ export class OCPPAuthServiceImpl implements OCPPAuthService {
       avgResponseTime: Math.round(avgResponseTime * 100) / 100,
       cacheHitRate: Math.round(cacheHitRate * 10000) / 100,
       failedAuth: this.metrics.failedAuth,
-      lastUpdated: this.metrics.lastReset,
+      lastUpdatedDate: this.metrics.lastReset,
       localUsageRate: Math.round(localUsageRate * 10000) / 100,
       rateLimit: rateLimitStats,
       remoteSuccessRate: Math.round(remoteSuccessRate * 10000) / 100,
index a78b14756ad34b91f098be351bc99db87bde0673..7a94730d6645ff5aac5c86c5d13351ae1a1166a9 100644 (file)
@@ -36,7 +36,7 @@ export class LocalAuthStrategy implements AuthStrategy {
   private localAuthListManager?: LocalAuthListManager
   private stats = {
     cacheHits: 0,
-    lastUpdated: new Date(),
+    lastUpdatedDate: new Date(),
     localListHits: 0,
     offlineDecisions: 0,
     totalRequests: 0,
@@ -134,7 +134,7 @@ export class LocalAuthStrategy implements AuthStrategy {
         }
       )
     } finally {
-      this.stats.lastUpdated = new Date()
+      this.stats.lastUpdatedDate = new Date()
     }
   }
 
@@ -184,7 +184,7 @@ export class LocalAuthStrategy implements AuthStrategy {
     this.isInitialized = false
     this.stats = {
       cacheHits: 0,
-      lastUpdated: new Date(),
+      lastUpdatedDate: new Date(),
       localListHits: 0,
       offlineDecisions: 0,
       totalRequests: 0,
index d7bcb7ca3ea96d86315ef827a94b43f3b526dbcd..71786a43735b6605ee75fac2e47c41938f107feb 100644 (file)
@@ -39,7 +39,7 @@ export class RemoteAuthStrategy implements AuthStrategy {
   private stats = {
     avgResponseTimeMs: 0,
     failedRemoteAuth: 0,
-    lastUpdated: new Date(),
+    lastUpdatedDate: new Date(),
     networkErrors: 0,
     successfulRemoteAuth: 0,
     timeoutErrors: 0,
@@ -156,7 +156,7 @@ export class RemoteAuthStrategy implements AuthStrategy {
       return undefined
     } finally {
       this.updateResponseTimeStats(startTime)
-      this.stats.lastUpdated = new Date()
+      this.stats.lastUpdatedDate = new Date()
     }
   }
 
@@ -187,7 +187,7 @@ export class RemoteAuthStrategy implements AuthStrategy {
     this.stats = {
       avgResponseTimeMs: 0,
       failedRemoteAuth: 0,
-      lastUpdated: new Date(),
+      lastUpdatedDate: new Date(),
       networkErrors: 0,
       successfulRemoteAuth: 0,
       timeoutErrors: 0,
index 4fa0224addff9b8c3bc498ee6e26ca541ced74e0..e233c4adca9dee625b49298ccdaee1e93a5856e2 100644 (file)
@@ -40,7 +40,7 @@ await describe('ChargingStation Configuration Management', async () => {
       if (station.bootNotificationResponse == null) {
         assert.fail('Expected bootNotificationResponse to be defined')
       }
-      assert.ok(station.bootNotificationResponse.interval > 0)
+      assert.strictEqual(station.bootNotificationResponse.interval > 0, true)
       assert.strictEqual(station.inPendingState(), true)
     })
 
@@ -140,7 +140,7 @@ await describe('ChargingStation Configuration Management', async () => {
       if (station.bootNotificationResponse == null) {
         assert.fail('Expected bootNotificationResponse to be defined')
       }
-      assert.ok(station.bootNotificationResponse.interval > 0)
+      assert.strictEqual(station.bootNotificationResponse.interval > 0, true)
       assert.strictEqual(station.inRejectedState(), true)
     })
 
@@ -756,7 +756,7 @@ await describe('ChargingStation Configuration Management', async () => {
       // Assert
       assert.notStrictEqual(mocks.webSocket.url, undefined)
       assert.strictEqual(typeof mocks.webSocket.url, 'string')
-      assert.ok(mocks.webSocket.url.length > 0)
+      assert.strictEqual(mocks.webSocket.url.length > 0, true)
     })
   })
 
@@ -783,7 +783,7 @@ await describe('ChargingStation Configuration Management', async () => {
         const pingInterval = station.getWebSocketPingInterval()
 
         // Assert - should return a valid interval value
-        assert.ok(pingInterval >= 0)
+        assert.strictEqual(pingInterval >= 0, true)
         assert.strictEqual(typeof pingInterval, 'number')
       })
     })
index d342f95e5e6605ce2c0a1cfe8f89e98f3dc4aed2..402df3eb27ee05be36b6cee5cf4826b3c14b430b 100644 (file)
@@ -246,7 +246,7 @@ await describe('ChargingStation Connector and EVSE State', async () => {
         assert.fail('Expected evseStatus to be defined')
       }
       assert.notStrictEqual(evseStatus.connectors, undefined)
-      assert.ok(evseStatus.connectors.size > 0)
+      assert.strictEqual(evseStatus.connectors.size > 0, true)
     })
 
     await it('should return undefined for getEvseStatus() with invalid EVSE IDs', () => {
index b77779fc72ca01b8b0a41cb55a73e4149e19bf2f..40a58ceb53b5083e17fbb1e482734e202b02b41f 100644 (file)
@@ -118,7 +118,7 @@ await describe('ChargingStation Resilience', async () => {
       mocks.webSocket.simulateMessage('invalid json')
 
       // Assert - Station should still be operational (not crashed)
-      assert.ok(station.connectors.size > 0)
+      assert.strictEqual(station.connectors.size > 0, true)
     })
 
     await it('should handle WebSocket error event gracefully', () => {
@@ -196,7 +196,7 @@ await describe('ChargingStation Resilience', async () => {
       mocks.webSocket.simulateClose(1006, 'Server unreachable')
 
       // Assert - Station should remain in valid state
-      assert.ok(station.connectors.size > 0)
+      assert.strictEqual(station.connectors.size > 0, true)
       assert.strictEqual(mocks.webSocket.readyState, 3) // CLOSED
     })
 
@@ -362,7 +362,7 @@ await describe('ChargingStation Resilience', async () => {
       // Note: Due to async nature, the message may be sent or buffered depending on timing
       // This test verifies the message is queued at minimum
       const stationWithQueue = station as unknown as { messageQueue: string[] }
-      assert.ok(stationWithQueue.messageQueue.length >= 0)
+      assert.strictEqual(stationWithQueue.messageQueue.length >= 0, true)
     })
 
     await it('should flush messages in FIFO order when connection restored', () => {
index dd528e64dd7314df4b6e71bdb6b58e40f9b3a390..51baa8c91015110b4fae3ae60a6cab38dbcbe047 100644 (file)
@@ -502,7 +502,7 @@ await describe('ChargingStation Transaction Management', async () => {
         // Assert - interval should be different (old cleared, new created)
         assert.notStrictEqual(secondInterval, undefined)
         assert.strictEqual(typeof secondInterval, 'object')
-        assert.ok(firstInterval !== secondInterval)
+        assert.notStrictEqual(firstInterval, secondInterval)
       })
     })
 
@@ -569,7 +569,7 @@ await describe('ChargingStation Transaction Management', async () => {
         // Assert - interval should be different
         assert.notStrictEqual(secondInterval, undefined)
         assert.strictEqual(typeof secondInterval, 'object')
-        assert.ok(firstInterval !== secondInterval)
+        assert.notStrictEqual(firstInterval, secondInterval)
       })
     })
 
index 829eabababd774c120b15732e301748a8165fcf3..c07cae1edd95cff7d36a2246e45f68956c19d2e5 100644 (file)
@@ -40,7 +40,7 @@ await describe('ChargingStation', async () => {
       const station = result.station
 
       assert.notStrictEqual(station, undefined)
-      assert.ok(station.connectors.size > 0)
+      assert.strictEqual(station.connectors.size > 0, true)
       assert.notStrictEqual(station.stationInfo, undefined)
 
       cleanupChargingStation(station)
index 09917b9ade15eec90c7dfc0586f0bcc86ab25903..dd5929b23e3b9018807cab600e7538a4023da821 100644 (file)
@@ -126,7 +126,7 @@ export const createMockAuthService = (overrides?: Partial<OCPPAuthService>): OCP
           avgResponseTime: 0,
           cacheHitRate: 0,
           failedAuth: 0,
-          lastUpdated: new Date(),
+          lastUpdatedDate: new Date(),
           localUsageRate: 1,
           remoteSuccessRate: 0,
           successfulAuth: 0,
index c3e669f57c85b80cbbe6b972a8fe9962333f4826..212f6c256cb06bdf6a1105d6c016d1a2a646701d 100644 (file)
@@ -131,10 +131,15 @@ await describe('UIMCPServer HTTP Integration', async () => {
   })
 
   afterEach(async () => {
+    const httpServer = Reflect.get(server, 'httpServer') as Server
+    if (httpServer.listening) {
+      await new Promise<void>(resolve => {
+        httpServer.close(() => {
+          resolve()
+        })
+      })
+    }
     server.stop()
-    await new Promise(resolve => {
-      setTimeout(resolve, 50)
-    })
     standardCleanup()
   })
 
index d9a5335de7c96523bfe72a689f4cfe38aa5e17af..34f8691009f37df99e1cd13e33bbb496384b89f2 100644 (file)
@@ -43,8 +43,8 @@ await describe('BaseError', async () => {
     const beforeNow = Date.now()
     const baseError = new BaseError()
     const afterNow = Date.now()
-    assert.ok(baseError.date.getTime() >= beforeNow - 1000)
-    assert.ok(baseError.date.getTime() <= afterNow + 1000)
+    assert.strictEqual(baseError.date.getTime() >= beforeNow - 1000, true)
+    assert.strictEqual(baseError.date.getTime() <= afterNow + 1000, true)
   })
 
   await it('should set name to subclass name when extended', () => {
index a6eb510588a62a38e7290cbe2eabbe038c48adc0..b69d270617c378a00e85ec9f61398e95aa2ff176 100644 (file)
@@ -236,11 +236,11 @@ await describe('ChargingStationConfigurationUtils', async () => {
       const result = buildEvsesStatus(station)
 
       const evse0Status = result[0][1].connectorsStatus as [number, ConnectorStatus][]
-      assert.ok(evse0Status.length > 0)
+      assert.strictEqual(evse0Status.length > 0, true)
       assert.strictEqual(evse0Status[0][0], 0)
 
       const evse1Status = result[1][1].connectorsStatus as [number, ConnectorStatus][]
-      assert.ok(evse1Status.length > 1)
+      assert.strictEqual(evse1Status.length > 1, true)
       assert.strictEqual(evse1Status[0][0], 1)
       assert.strictEqual(evse1Status[1][0], 2)
       assert.strictEqual(evse1Status[1][1].availability, AvailabilityType.Inoperative)
index 2e5dbae54da045d3740b5f2b90ac7a1e87cf0077..056af9f99494c26ebc215c61681f42b906f712cd 100644 (file)
@@ -226,8 +226,8 @@ await describe('Utils', async () => {
   await it('should generate cryptographically secure random numbers between 0 and 1', () => {
     const random = secureRandom()
     assert.ok(typeof random === 'number')
-    assert.ok(random >= 0)
-    assert.ok(random < 1)
+    assert.strictEqual(random >= 0, true)
+    assert.strictEqual(random < 1, true)
   })
 
   await it('should round numbers to specified decimal places correctly', () => {
@@ -248,8 +248,8 @@ await describe('Utils', async () => {
   await it('should generate random floats within specified range', () => {
     let randomFloat = getRandomFloat()
     assert.ok(typeof randomFloat === 'number')
-    assert.ok(randomFloat >= 0)
-    assert.ok(randomFloat <= Number.MAX_VALUE)
+    assert.strictEqual(randomFloat >= 0, true)
+    assert.strictEqual(randomFloat <= Number.MAX_VALUE, true)
     assert.notDeepStrictEqual(randomFloat, getRandomFloat())
     assert.throws(
       () => {
@@ -264,8 +264,8 @@ await describe('Utils', async () => {
       { message: /Invalid interval/ }
     )
     randomFloat = getRandomFloat(0, -Number.MAX_VALUE)
-    assert.ok(randomFloat >= -Number.MAX_VALUE)
-    assert.ok(randomFloat <= 0)
+    assert.strictEqual(randomFloat >= -Number.MAX_VALUE, true)
+    assert.strictEqual(randomFloat <= 0, true)
   })
 
   await it('should extract numeric values from timestamped circular buffer', () => {
@@ -558,39 +558,39 @@ await describe('Utils', async () => {
 
     // retryNumber = 0: 2^0 * 100 = 100ms base
     const delay0 = exponentialDelay(0)
-    assert.ok(delay0 >= 100)
-    assert.ok(delay0 <= 120) // 100 + 20% max jitter
+    assert.strictEqual(delay0 >= 100, true)
+    assert.strictEqual(delay0 <= 120, true) // 100 + 20% max jitter
 
     // retryNumber = 1: 2^1 * 100 = 200ms base
     const delay1 = exponentialDelay(1)
-    assert.ok(delay1 >= 200)
-    assert.ok(delay1 <= 240) // 200 + 20% max jitter
+    assert.strictEqual(delay1 >= 200, true)
+    assert.strictEqual(delay1 <= 240, true) // 200 + 20% max jitter
 
     // retryNumber = 2: 2^2 * 100 = 400ms base
     const delay2 = exponentialDelay(2)
-    assert.ok(delay2 >= 400)
-    assert.ok(delay2 <= 480) // 400 + 20% max jitter
+    assert.strictEqual(delay2 >= 400, true)
+    assert.strictEqual(delay2 <= 480, true) // 400 + 20% max jitter
 
     // retryNumber = 3: 2^3 * 100 = 800ms base
     const delay3 = exponentialDelay(3)
-    assert.ok(delay3 >= 800)
-    assert.ok(delay3 <= 960) // 800 + 20% max jitter
+    assert.strictEqual(delay3 >= 800, true)
+    assert.strictEqual(delay3 <= 960, true) // 800 + 20% max jitter
   })
 
   await it('should calculate exponential delay with custom delay factor', () => {
     // Custom delayFactor = 50ms
     const delay0 = exponentialDelay(0, 50)
-    assert.ok(delay0 >= 50)
-    assert.ok(delay0 <= 60) // 50 + 20% max jitter
+    assert.strictEqual(delay0 >= 50, true)
+    assert.strictEqual(delay0 <= 60, true) // 50 + 20% max jitter
 
     const delay1 = exponentialDelay(1, 50)
-    assert.ok(delay1 >= 100)
-    assert.ok(delay1 <= 120)
+    assert.strictEqual(delay1 >= 100, true)
+    assert.strictEqual(delay1 <= 120, true)
 
     // Custom delayFactor = 200ms
     const delay2 = exponentialDelay(2, 200)
-    assert.ok(delay2 >= 800) // 2^2 * 200 = 800
-    assert.ok(delay2 <= 960)
+    assert.strictEqual(delay2 >= 800, true) // 2^2 * 200 = 800
+    assert.strictEqual(delay2 <= 960, true)
   })
 
   await it('should follow 2^n exponential growth pattern', () => {
@@ -608,8 +608,8 @@ await describe('Utils', async () => {
     for (let i = 1; i < delays.length; i++) {
       const ratio = delays[i] / delays[i - 1]
       // Allow for jitter variance - ratio should be roughly 2x
-      assert.ok(ratio > 1.5)
-      assert.ok(ratio < 2.5)
+      assert.strictEqual(ratio > 1.5, true)
+      assert.strictEqual(ratio < 2.5, true)
     }
   })
 
@@ -627,7 +627,7 @@ await describe('Utils', async () => {
 
     // With jitter, we expect at least some variation
     // (unlikely to get 10 identical values with secure random)
-    assert.ok(delays.size > 1)
+    assert.strictEqual(delays.size > 1, true)
   })
 
   await it('should keep jitter within 0-20% range of base delay', () => {
@@ -642,27 +642,27 @@ await describe('Utils', async () => {
       const jitter = delay - baseDelay
 
       // Jitter should be non-negative and at most 20% of base delay
-      assert.ok(jitter >= 0)
-      assert.ok(jitter <= baseDelay * 0.2)
+      assert.strictEqual(jitter >= 0, true)
+      assert.strictEqual(jitter <= baseDelay * 0.2, true)
     }
   })
 
   await it('should handle edge cases (default retry, large retry, small factor)', () => {
     // Default retryNumber (0)
     const defaultRetry = exponentialDelay()
-    assert.ok(defaultRetry >= 100) // 2^0 * 100
-    assert.ok(defaultRetry <= 120)
+    assert.strictEqual(defaultRetry >= 100, true) // 2^0 * 100
+    assert.strictEqual(defaultRetry <= 120, true)
 
     // Large retry number (verify no overflow issues)
     const largeRetry = exponentialDelay(10, 100)
     // 2^10 * 100 = 102400ms base
-    assert.ok(largeRetry >= 102400)
-    assert.ok(largeRetry <= 122880) // 102400 + 20%
+    assert.strictEqual(largeRetry >= 102400, true)
+    assert.strictEqual(largeRetry <= 122880, true) // 102400 + 20%
 
     // Very small delay factor
     const smallFactor = exponentialDelay(2, 1)
-    assert.ok(smallFactor >= 4) // 2^2 * 1
-    assert.ok(smallFactor < 5) // 4 + 20%
+    assert.strictEqual(smallFactor >= 4, true) // 2^2 * 1
+    assert.strictEqual(smallFactor < 5, true) // 4 + 20%
   })
 
   await it('should calculate appropriate delays for WebSocket reconnection scenarios', () => {
@@ -671,26 +671,26 @@ await describe('Utils', async () => {
 
     // First reconnect attempt (retry 1)
     const firstDelay = exponentialDelay(1, delayFactor)
-    assert.ok(firstDelay >= 200) // 2^1 * 100
-    assert.ok(firstDelay <= 240)
+    assert.strictEqual(firstDelay >= 200, true) // 2^1 * 100
+    assert.strictEqual(firstDelay <= 240, true)
 
     // After several failures (retry 5)
     const fifthDelay = exponentialDelay(5, delayFactor)
-    assert.ok(fifthDelay >= 3200) // 2^5 * 100
-    assert.ok(fifthDelay <= 3840)
+    assert.strictEqual(fifthDelay >= 3200, true) // 2^5 * 100
+    assert.strictEqual(fifthDelay <= 3840, true)
 
     // Maximum practical retry (retry 10 = ~102 seconds)
     const maxDelay = exponentialDelay(10, delayFactor)
-    assert.ok(maxDelay >= 102400) // ~102 seconds
-    assert.ok(maxDelay <= 122880)
+    assert.strictEqual(maxDelay >= 102400, true) // ~102 seconds
+    assert.strictEqual(maxDelay <= 122880, true)
   })
 
   await it('should return timestamped log prefix with optional string', () => {
     const result = logPrefix()
     assert.strictEqual(typeof result, 'string')
-    assert.ok(result.length > 0)
+    assert.strictEqual(result.length > 0, true)
     const withPrefix = logPrefix(' Test |')
-    assert.ok(withPrefix.includes(' Test |'))
+    assert.strictEqual(withPrefix.includes(' Test |'), true)
   })
 
   await it('should deep merge objects with source overriding target', () => {
@@ -754,17 +754,17 @@ await describe('Utils', async () => {
 
   await it('should generate random float rounded to specified scale', () => {
     const result = getRandomFloatRounded(10, 0, 2)
-    assert.ok(result >= 0)
-    assert.ok(result <= 10)
+    assert.strictEqual(result >= 0, true)
+    assert.strictEqual(result <= 10, true)
     // Check rounding to 2 decimal places
     const decimalStr = result.toString()
     if (decimalStr.includes('.')) {
-      assert.ok(decimalStr.split('.')[1].length <= 2)
+      assert.strictEqual(decimalStr.split('.')[1].length <= 2, true)
     }
     // Default scale
     const defaultScale = getRandomFloatRounded(10, 0)
-    assert.ok(defaultScale >= 0)
-    assert.ok(defaultScale <= 10)
+    assert.strictEqual(defaultScale >= 0, true)
+    assert.strictEqual(defaultScale <= 10, true)
   })
 
   await it('should generate fluctuated random float within percentage range', () => {
@@ -772,8 +772,8 @@ await describe('Utils', async () => {
     assert.strictEqual(getRandomFloatFluctuatedRounded(100, 0), 100)
     // 10% fluctuation: 100 ± 10
     const result = getRandomFloatFluctuatedRounded(100, 10)
-    assert.ok(result >= 90)
-    assert.ok(result <= 110)
+    assert.strictEqual(result >= 90, true)
+    assert.strictEqual(result <= 110, true)
     // Invalid fluctuation percent
     assert.throws(() => {
       getRandomFloatFluctuatedRounded(100, -1)
@@ -783,8 +783,8 @@ await describe('Utils', async () => {
     }, RangeError)
     // Negative static value with fluctuation
     const negResult = getRandomFloatFluctuatedRounded(-100, 10)
-    assert.ok(negResult >= -110)
-    assert.ok(negResult <= -90)
+    assert.strictEqual(negResult >= -110, true)
+    assert.strictEqual(negResult <= -90, true)
   })
 
   await it('should detect Cloud Foundry environment from VCAP_APPLICATION', () => {
index 799b39e4bd2dfb5a149a2a2099c740e876eb52c7..4a6da2542c4203f904855ebe6bc6d383678618ac 100644 (file)
@@ -112,24 +112,24 @@ await describe('WorkerUtils', async () => {
       results.push(randomized)
 
       // Each result should be within ±20% of base delay
-      assert.ok(randomized >= baseDelay - tolerance)
-      assert.ok(randomized <= baseDelay + tolerance)
+      assert.strictEqual(randomized >= baseDelay - tolerance, true)
+      assert.strictEqual(randomized <= baseDelay + tolerance, true)
     }
 
     // Verify we get some variation (not all values identical)
     const uniqueValues = new Set(results)
-    assert.ok(uniqueValues.size > 1)
+    assert.strictEqual(uniqueValues.size > 1, true)
 
     // Test with zero delay
     const zeroResult = randomizeDelay(0)
-    assert.ok(zeroResult >= 0)
-    assert.ok(zeroResult <= 0)
+    assert.strictEqual(zeroResult >= 0, true)
+    assert.strictEqual(zeroResult <= 0, true)
 
     // Test with negative delay (edge case)
     const negativeDelay = -100
     const negativeResult = randomizeDelay(negativeDelay)
     const negativeTolerance = Math.abs(negativeDelay) * 0.2
-    assert.ok(negativeResult >= negativeDelay - negativeTolerance)
-    assert.ok(negativeResult <= negativeDelay + negativeTolerance)
+    assert.strictEqual(negativeResult >= negativeDelay - negativeTolerance, true)
+    assert.strictEqual(negativeResult <= negativeDelay + negativeTolerance, true)
   })
 })