Skip to content

Commit 114c02c

Browse files
committed
fix(test): pass modifier flags on WheelEvent for activationKeys tests
syncModifierKeys reads ctrlKey/metaKey from the event itself (required for iframe support), so fireEvent.keyDown alone is insufficient — the subsequent WheelEvent must carry the modifier flag just like a real browser would. Also adds a positive assertion for the predicate-based activationKeys test. Made-with: Cursor
1 parent 83a269a commit 114c02c

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

__tests__/features/props/wheel-props.spec.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,24 +87,33 @@ describe("ReactZoomPanPinchProps.wheel", () => {
8787
);
8888
expect(ref.current!.instance.state.scale).toBe(1);
8989

90-
fireEvent.keyDown(document, { key: "Control" });
90+
// Real browsers include ctrlKey on WheelEvent when Control is held;
91+
// syncModifierKeys reads it so keyDown alone is not enough in tests.
9192
fireEvent(
9293
content,
93-
new WheelEvent("wheel", { bubbles: true, deltaY: -5 }),
94+
new WheelEvent("wheel", { bubbles: true, deltaY: -5, ctrlKey: true }),
9495
);
9596
expect(ref.current!.instance.state.scale).toBeGreaterThan(1);
9697
});
9798

9899
it("supports predicate function for activationKeys", () => {
99100
const { content, ref } = renderApp({
100-
wheel: { activationKeys: (keys: string[]) => keys.includes("Meta") },
101+
wheel: {
102+
activationKeys: (keys: string[]) => keys.includes("Meta"),
103+
},
101104
});
102105
userEvent.hover(content);
103106
fireEvent(
104107
content,
105108
new WheelEvent("wheel", { bubbles: true, deltaY: -5 }),
106109
);
107110
expect(ref.current!.instance.state.scale).toBe(1);
111+
112+
fireEvent(
113+
content,
114+
new WheelEvent("wheel", { bubbles: true, deltaY: -5, metaKey: true }),
115+
);
116+
expect(ref.current!.instance.state.scale).toBeGreaterThan(1);
108117
});
109118
});
110119

0 commit comments

Comments
 (0)