* Closes the menu.
()
| 398 | * Closes the menu. |
| 399 | */ |
| 400 | async close(): Promise<void> { |
| 401 | let menu = this.getMenu(); |
| 402 | if (menu) { |
| 403 | act(() => menu.focus()); |
| 404 | await this.user.keyboard('[Escape]'); |
| 405 | |
| 406 | await waitFor(() => { |
| 407 | if (document.activeElement !== this.getTrigger()) { |
| 408 | throw new Error( |
| 409 | `Expected the document.activeElement after closing the menu to be the menu trigger but got ${document.activeElement}` |
| 410 | ); |
| 411 | } else { |
| 412 | return true; |
| 413 | } |
| 414 | }); |
| 415 | |
| 416 | if (document.contains(menu)) { |
| 417 | throw new Error('Expected the menu to not be in the document after closing it.'); |
| 418 | } |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | /** |
| 423 | * Returns the menu's trigger. |
nothing calls this directly
no test coverage detected