Skip to content

Commit

Permalink
test: try to fix broken tests with mocking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mikerourke committed Jan 7, 2025
1 parent b5da347 commit 4e8a9cb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/__tests__/getChordDisplay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Check failure on line 14 in src/__tests__/getChordDisplay.test.ts

View workflow job for this annotation

GitHub Actions / Run Checks

error: expect(received).toBe(expected)

+ Shift + Left Click + C" Received: "Alt + Shift + Left Click + C" at /home/runner/work/keytar/keytar/src/__tests__/getChordDisplay.test.ts:14:20
});

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 @@ -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,
Expand Down

0 comments on commit 4e8a9cb

Please sign in to comment.