From 4bcdc67aa091f103147e31055863a8f8438cfc38 Mon Sep 17 00:00:00 2001 From: SnapOtter Date: Sat, 9 May 2026 11:13:04 +0800 Subject: [PATCH] fix: make dead zone test deterministic and remove unused parameter Replace Math.random() with deterministic modular arithmetic to prevent flaky CI failures. Remove unused index parameter from Array.from callback. --- tests/unit/auto-enhance.test.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/unit/auto-enhance.test.ts b/tests/unit/auto-enhance.test.ts index 911d2458..aef379ff 100644 --- a/tests/unit/auto-enhance.test.ts +++ b/tests/unit/auto-enhance.test.ts @@ -105,9 +105,7 @@ describe("analyzeImage", () => { // Wide spread centered at 128 gives stdev ~60 (contrast ~50) and mean ~128 (exposure ~50). // Both scores land inside the [40,60] dead zone, so corrections should be zero. const midGrayBuffer = await sharp( - Buffer.from( - Array.from({ length: 100 * 100 * 3 }, (_, i) => 24 + Math.floor(Math.random() * 208)), - ), + Buffer.from(Array.from({ length: 100 * 100 * 3 }, (_, i) => 24 + ((i * 97) % 208))), { raw: { width: 100, height: 100, channels: 3 } }, ) .png()