Skip to content

Commit 8eaa7a6

Browse files
committed
test(cdk/menu): fix test that fails locally
Fixes a test in the CDK menu that only fails locally.
1 parent fb4e395 commit 8eaa7a6

File tree

1 file changed

+41
-49
lines changed

1 file changed

+41
-49
lines changed

src/cdk/menu/menu.spec.ts

Lines changed: 41 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -204,23 +204,23 @@ describe('Menu', () => {
204204
function hover(from: Point, to: Point, inMenu: HTMLElement, duration: number) {
205205
const getNextPoint = getNextPointIterator(from, to);
206206

207-
let currPoint: Point | null = from;
208-
let currElement = getElementAt(currPoint);
207+
let currentPoint: Point | null = from;
208+
let currElement = getElementAt(currentPoint);
209209

210210
const timeout = duration / (to.x - from.x);
211211

212212
let numEnters = 0;
213-
while (currPoint) {
214-
mousemove(inMenu, currPoint);
215-
const nextElement = getElementAt(currPoint);
213+
while (currentPoint) {
214+
mousemove(inMenu, currentPoint);
215+
const nextElement = getElementAt(currentPoint);
216216
if (nextElement !== currElement && nextElement instanceof HTMLButtonElement) {
217217
numEnters++;
218218
mouseout(currElement);
219-
mouseenter(nextElement, currPoint);
219+
mouseenter(nextElement, currentPoint);
220220
currElement = nextElement;
221221
fixture.detectChanges();
222222
}
223-
currPoint = getNextPoint();
223+
currentPoint = getNextPoint();
224224
tick(timeout);
225225
}
226226
return numEnters;
@@ -243,27 +243,23 @@ describe('Menu', () => {
243243
};
244244
}
245245

246-
it(
247-
'should close the edit menu when hovering directly down from the edit menu trigger to' +
248-
' the print item without waiting',
249-
fakeAsync(() => {
250-
openFileMenu();
251-
openMenuOnHover(nativeEditTrigger!);
252-
const editPosition = nativeEditTrigger!.getBoundingClientRect();
253-
const printPosition = nativeFileButtons![4].getBoundingClientRect();
254-
255-
const numEnterEvents = hover(
256-
editPosition,
257-
{x: printPosition.x + 5, y: printPosition.y + 1},
258-
nativeMenus[0],
259-
100,
260-
);
261-
detectChanges();
246+
it('should close the edit menu when hovering directly down from the edit menu trigger to the print item without waiting', fakeAsync(() => {
247+
openFileMenu();
248+
openMenuOnHover(nativeEditTrigger!);
249+
const editPosition = nativeEditTrigger!.getBoundingClientRect();
250+
const printPosition = nativeFileButtons![4].getBoundingClientRect();
251+
252+
const numEnterEvents = hover(
253+
{x: editPosition.x, y: editPosition.y + 1},
254+
{x: printPosition.x + 5, y: printPosition.y + 1},
255+
nativeMenus[0],
256+
100,
257+
);
258+
detectChanges();
262259

263-
expect(numEnterEvents).toBe(4);
264-
expect(nativeMenus.length).toBe(1);
265-
}),
266-
);
260+
expect(numEnterEvents).toBe(4);
261+
expect(nativeMenus.length).toBe(1);
262+
}));
267263

268264
it('should close the edit menu after moving towards submenu and stopping', fakeAsync(() => {
269265
openFileMenu();
@@ -448,29 +444,25 @@ describe('Menu', () => {
448444
};
449445
}
450446

451-
it(
452-
'should close the edit menu when hovering directly up from the edit menu trigger to' +
453-
' the print item without waiting',
454-
fakeAsync(() => {
455-
openFileMenu();
456-
openMenuOnHover(nativeEditTrigger!);
457-
458-
const editPosition = nativeEditTrigger!.getBoundingClientRect();
459-
const printPosition = nativeFileButtons![0].getBoundingClientRect();
460-
461-
const numEnterEvents = hover(
462-
{x: editPosition.x + editPosition.width / 2, y: editPosition.y + 5},
463-
{x: printPosition.x + 10, y: printPosition.y - 10},
464-
nativeMenus[0],
465-
100,
466-
);
467-
detectChanges();
468-
flush();
447+
it('should close the edit menu when hovering directly up from the edit menu trigger to the print item without waiting', fakeAsync(() => {
448+
openFileMenu();
449+
openMenuOnHover(nativeEditTrigger!);
450+
451+
const editPosition = nativeEditTrigger!.getBoundingClientRect();
452+
const printPosition = nativeFileButtons![0].getBoundingClientRect();
453+
454+
const numEnterEvents = hover(
455+
{x: editPosition.x + editPosition.width / 2, y: editPosition.y + 5},
456+
{x: printPosition.x + 10, y: printPosition.y - 10},
457+
nativeMenus[0],
458+
100,
459+
);
460+
detectChanges();
461+
flush();
469462

470-
expect(numEnterEvents).toBe(4);
471-
expect(nativeMenus.length).toBe(1);
472-
}),
473-
);
463+
expect(numEnterEvents).toBe(4);
464+
expect(nativeMenus.length).toBe(1);
465+
}));
474466

475467
it('should close the edit menu after moving towards submenu and stopping', fakeAsync(() => {
476468
openFileMenu();

0 commit comments

Comments
 (0)