* Fakes mouse hover events from some source point to some target point. Along the way, emits * mouse move events and mouse enter events when the element under the mouse changes. * * It assumes that moves will occur left to right and down. * @param from the starting point
(from: Point, to: Point, inMenu: HTMLElement, duration: number)
| 190 | * @return the number of elements the mouse entered into. |
| 191 | */ |
| 192 | function hover(from: Point, to: Point, inMenu: HTMLElement, duration: number) { |
| 193 | const getNextPoint = getNextPointIterator(from, to); |
| 194 | |
| 195 | let currentPoint: Point | null = from; |
| 196 | let currElement = getElementAt(currentPoint); |
| 197 | |
| 198 | const timeout = duration / (to.x - from.x); |
| 199 | |
| 200 | let numEnters = 0; |
| 201 | while (currentPoint) { |
| 202 | mousemove(inMenu, currentPoint); |
| 203 | const nextElement = getElementAt(currentPoint); |
| 204 | if (nextElement !== currElement && nextElement instanceof HTMLButtonElement) { |
| 205 | numEnters++; |
| 206 | mouseout(currElement); |
| 207 | mouseenter(nextElement, currentPoint); |
| 208 | currElement = nextElement; |
| 209 | fixture.detectChanges(); |
| 210 | } |
| 211 | currentPoint = getNextPoint(); |
| 212 | tick(timeout); |
| 213 | } |
| 214 | return numEnters; |
| 215 | } |
| 216 | |
| 217 | /** |
| 218 | * Get a function which determines the next point to generate when moving from one point to |
no test coverage detected
searching dependent graphs…