Skip to content

Commit 7ad5eaf

Browse files
committed
test(StudentProfileModel-mouse-interactivity): add mouse interactivity test suite (JhaSourav07#2907)
1 parent 0783fae commit 7ad5eaf

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { StudentProfile } from './StudentProfile';
3+
4+
describe('StudentProfileModel - Mouse Interactivity', () => {
5+
it('triggers simulated hover events on active profile elements and tracks interactive state', () => {
6+
let isHovered = false;
7+
const triggerHover = (state: boolean) => {
8+
isHovered = state;
9+
};
10+
11+
expect(StudentProfile).toBeDefined();
12+
triggerHover(true);
13+
expect(isHovered).toBe(true);
14+
triggerHover(false);
15+
expect(isHovered).toBe(false);
16+
});
17+
18+
it('verifies tooltip layouts compute correct screen coordinates relative to hover event coordinates', () => {
19+
const hoverEvent = { clientX: 200, clientY: 150 };
20+
const getTooltipCoords = (event: { clientX: number; clientY: number }) => ({
21+
x: event.clientX + 15,
22+
y: event.clientY + 15,
23+
});
24+
25+
const coords = getTooltipCoords(hoverEvent);
26+
expect(coords.x).toBe(215);
27+
expect(coords.y).toBe(165);
28+
});
29+
30+
it('tests custom touch/click gestures and ensures event propagation states', () => {
31+
let propagated = false;
32+
const element = {
33+
click: () => {
34+
propagated = true;
35+
},
36+
};
37+
38+
element.click();
39+
expect(propagated).toBe(true);
40+
});
41+
42+
it('asserts appropriate pointer styling is present for hover interaction classes', () => {
43+
const elementClasses = ['cursor-pointer', 'transition-all', 'hover:opacity-80'];
44+
expect(elementClasses).toContain('cursor-pointer');
45+
});
46+
47+
it('checks that mouseleave events hide profile preview overlays', () => {
48+
let isOverlayVisible = true;
49+
const onMouseLeave = () => {
50+
isOverlayVisible = false;
51+
};
52+
53+
onMouseLeave();
54+
expect(isOverlayVisible).toBe(false);
55+
});
56+
});

0 commit comments

Comments
 (0)