const test = require("node:test");
const assert = require("node:assert");
const F = require("./flash.js");

test("minSafeDurationMs: N transitions need N/3 seconds", () => {
  assert.strictEqual(F.minSafeDurationMs(3), 1000); // 3 flashes in >=1s
  assert.strictEqual(F.minSafeDurationMs(6), 2000);
  assert.strictEqual(F.minSafeDurationMs(0), 0);
  assert.strictEqual(F.minSafeDurationMs(1), 1000 / 3);
});

test("clampDurationMs: stretches only when too fast", () => {
  assert.strictEqual(F.clampDurationMs(2000, 3), 2000); // already safe
  assert.strictEqual(F.clampDurationMs(200, 3), 1000);  // too fast -> clamped up
  assert.strictEqual(F.clampDurationMs(500, 1), 500);   // single transition, slow enough
});
