feat: enhance navigation tests for middle mouse button interactions

This commit is contained in:
Yunus M
2026-03-09 20:00:34 +05:30
parent 4926481d7f
commit fe080b6376

View File

@@ -20,6 +20,7 @@ describe('navigation utilities', () => {
({
metaKey: false,
ctrlKey: false,
button: 0,
...overrides,
} as MouseEvent);
@@ -50,6 +51,11 @@ describe('navigation utilities', () => {
} as Partial<MouseEvent>);
expect(isModifierKeyPressed(event)).toBe(false);
});
it('returns true when middle mouse button is used', () => {
const event = createMouseEvent({ button: 1 });
expect(isModifierKeyPressed(event)).toBe(true);
});
});
describe('openInNewTab', () => {
@@ -98,6 +104,14 @@ describe('navigation utilities', () => {
expect(mockNavigate).not.toHaveBeenCalled();
});
it('opens new tab when middle mouse button is used', () => {
const event = { metaKey: false, ctrlKey: false, button: 1 } as MouseEvent;
navigateToPage('/services', mockNavigate, event);
expect(window.open).toHaveBeenCalledWith('/services', '_blank');
expect(mockNavigate).not.toHaveBeenCalled();
});
it('calls navigate callback when no modifier key is pressed', () => {
const event = { metaKey: false, ctrlKey: false } as MouseEvent;
navigateToPage('/services', mockNavigate, event);