Skip to content

Commit 1a738a5

Browse files
committed
test: tweak mocking test code again
1 parent 4e8a9cb commit 1a738a5

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

src/__tests__/getChordDisplay.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,12 @@ import { Key, Modifier, MouseButton, MouseEventButton } from "../types.ts";
55

66
describe("the getChordDisplay function", () => {
77
it("returns the display for a chord", () => {
8-
mock.module("@laserware/arcade", () => ({
9-
isPlatform: (platform: string) => platform === "mac",
10-
}));
11-
128
const result = getChordDisplay(Modifier.Alt | Modifier.Shift | Key.LetterC | MouseButton.Left);
139

1410
expect(result).toBe("⌥ + Shift + Left Click + C");
1511
});
1612

1713
it("returns the chord display for a keyboard event", () => {
18-
mock.module("@laserware/arcade", () => ({
19-
isPlatform: (platform: string) => platform === "mac",
20-
}));
21-
2214
const event = new KeyboardEvent("keydown", {
2315
key: "ArrowDown",
2416
altKey: true,
@@ -33,10 +25,6 @@ describe("the getChordDisplay function", () => {
3325
});
3426

3527
it("returns the chord display for a mouse event", () => {
36-
mock.module("@laserware/arcade", () => ({
37-
isPlatform: (platform: string) => platform === "mac",
38-
}));
39-
4028
const event = new MouseEvent("mousedown", {
4129
buttons: MouseEventButton.Left,
4230
altKey: true,

test.setup.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
// noinspection JSConstantReassignment
22

3-
import { afterAll, afterEach, beforeAll } from "bun:test";
3+
import { afterAll, afterEach, beforeAll, mock } from "bun:test";
44

55
// @ts-ignore
66
import JSDOM from "jsdom";
77

88
const globalProperties: any[] = [];
99

10+
mock.module("@laserware/arcade", () => ({
11+
isPlatform: (platform: string) => platform === "mac",
12+
}));
13+
1014
beforeAll(() => {
1115
const jsdom = new JSDOM.JSDOM(
1216
`<!doctype html><html><head><meta charset="utf-8"></head><body></body></html>`,

0 commit comments

Comments
 (0)