Skip to content

Commit

Permalink
test: tweak mocking test code again
Browse files Browse the repository at this point in the history
  • Loading branch information
mikerourke committed Jan 7, 2025
1 parent 4e8a9cb commit 1a738a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
12 changes: 0 additions & 12 deletions src/__tests__/getChordDisplay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion test.setup.ts
Original file line number Diff line number Diff line change
@@ -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(
`<!doctype html><html><head><meta charset="utf-8"></head><body></body></html>`,
Expand Down

0 comments on commit 1a738a5

Please sign in to comment.