(opts: {
side: Side;
align?: Alignment;
element: Partial<DOMRect>;
popover: Partial<DOMRect>;
})
| 196 | // jsdom doesn't lay anything out, so we feed both the element and the popover |
| 197 | // their boxes, then refresh to run the positioning against those boxes. |
| 198 | function positionArrow(opts: { |
| 199 | side: Side; |
| 200 | align?: Alignment; |
| 201 | element: Partial<DOMRect>; |
| 202 | popover: Partial<DOMRect>; |
| 203 | }): Promise<void> { |
| 204 | const el = document.querySelector<HTMLElement>("#intro")!; |
| 205 | el.getBoundingClientRect = () => rect(opts.element); |
| 206 | // jsdom has no scrollIntoView; off-screen element boxes would otherwise throw. |
| 207 | el.scrollIntoView = () => {}; |
| 208 | |
| 209 | const d = createDriver({ animate: false }); |
| 210 | d.highlight({ element: "#intro", popover: { title: "Intro", side: opts.side, align: opts.align ?? "start" } }); |
| 211 | |
| 212 | const wrapper = popoverEl() as HTMLElement; |
| 213 | wrapper.getBoundingClientRect = () => rect(opts.popover); |
| 214 | |
| 215 | d.refresh(); |
| 216 | return nextFrame(); |
| 217 | } |
| 218 | |
| 219 | it("points the arrow at the element's vertical center for a left/right placement", async () => { |
| 220 | // Element sits to the right with its vertical center at y=230; popover box |
no test coverage detected
searching dependent graphs…