From 4e8a9cb379615efe1d625ae4f3cc43acae2c9c06 Mon Sep 17 00:00:00 2001 From: Mike Rourke Date: Mon, 6 Jan 2025 18:23:43 -0600 Subject: [PATCH] test: try to fix broken tests with mocking changes --- src/__tests__/getChordDisplay.test.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/__tests__/getChordDisplay.test.ts b/src/__tests__/getChordDisplay.test.ts index 2f10e46..7c3860c 100644 --- a/src/__tests__/getChordDisplay.test.ts +++ b/src/__tests__/getChordDisplay.test.ts @@ -3,18 +3,22 @@ import { describe, expect, it, mock } from "bun:test"; import { getChordDisplay } from "../getChordDisplay.ts"; import { Key, Modifier, MouseButton, MouseEventButton } from "../types.ts"; -mock.module("@laserware/arcade", () => ({ - isPlatform: () => true, -})); - describe("the getChordDisplay function", () => { it("returns the display for a chord", () => { + mock.module("@laserware/arcade", () => ({ + isPlatform: (platform: string) => platform === "mac", + })); + const result = getChordDisplay(Modifier.Alt | Modifier.Shift | Key.LetterC | MouseButton.Left); expect(result).toBe("⌥ + Shift + Left Click + C"); }); it("returns the chord display for a keyboard event", () => { + mock.module("@laserware/arcade", () => ({ + isPlatform: (platform: string) => platform === "mac", + })); + const event = new KeyboardEvent("keydown", { key: "ArrowDown", altKey: true, @@ -29,6 +33,10 @@ describe("the getChordDisplay function", () => { }); it("returns the chord display for a mouse event", () => { + mock.module("@laserware/arcade", () => ({ + isPlatform: (platform: string) => platform === "mac", + })); + const event = new MouseEvent("mousedown", { buttons: MouseEventButton.Left, altKey: true,