From e69736eb4556cf28bb000000fd2e5c0a426da364 Mon Sep 17 00:00:00 2001 From: Grace Kind Date: Mon, 10 Aug 2026 13:02:14 -0400 Subject: [PATCH] Mock time for zoom tests --- tests/unit/specs/zoomHelpers.test.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/unit/specs/zoomHelpers.test.js b/tests/unit/specs/zoomHelpers.test.js index 7dcc4d5f..9a0a5139 100644 --- a/tests/unit/specs/zoomHelpers.test.js +++ b/tests/unit/specs/zoomHelpers.test.js @@ -1,7 +1,6 @@ import { describe, it, beforeEach } from "node:test"; import assert from "node:assert/strict"; import { enablePinchZoom } from "/js/zoomHelpers.js"; -import { wait } from "/js/utils.js"; function pointerEvent( type, @@ -246,7 +245,9 @@ describe("enablePinchZoom", () => { assert.equal(control.getState().scale, 2.5); }); - it("does not treat two slow taps as a double-tap", async () => { + it("does not treat two slow taps as a double-tap", (t) => { + let clock = 0; + t.mock.method(performance, "now", () => clock); const { img, control } = createZoomableImg({ trackScale: true }); const tap = (pointerId) => { @@ -259,7 +260,7 @@ describe("enablePinchZoom", () => { }; tap(1); - await wait(350); + clock += 350; tap(2); assert.equal(control.getState().scale, 1); -- 2.51.2