From 1a738a511a98e8f307699919bbc534a6f52f8bcb Mon Sep 17 00:00:00 2001 From: Mike Rourke Date: Mon, 6 Jan 2025 18:30:04 -0600 Subject: [PATCH] test: tweak mocking test code again --- src/__tests__/getChordDisplay.test.ts | 12 ------------ test.setup.ts | 6 +++++- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/__tests__/getChordDisplay.test.ts b/src/__tests__/getChordDisplay.test.ts index 7c3860c..cf05480 100644 --- a/src/__tests__/getChordDisplay.test.ts +++ b/src/__tests__/getChordDisplay.test.ts @@ -5,20 +5,12 @@ import { Key, Modifier, MouseButton, MouseEventButton } from "../types.ts"; 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, @@ -33,10 +25,6 @@ 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, diff --git a/test.setup.ts b/test.setup.ts index e5ffcc9..b941496 100644 --- a/test.setup.ts +++ b/test.setup.ts @@ -1,12 +1,16 @@ // noinspection JSConstantReassignment -import { afterAll, afterEach, beforeAll } from "bun:test"; +import { afterAll, afterEach, beforeAll, mock } from "bun:test"; // @ts-ignore import JSDOM from "jsdom"; const globalProperties: any[] = []; +mock.module("@laserware/arcade", () => ({ + isPlatform: (platform: string) => platform === "mac", +})); + beforeAll(() => { const jsdom = new JSDOM.JSDOM( ``,