* Closes the select.
()
| 105 | * Closes the select. |
| 106 | */ |
| 107 | async close(): Promise<void> { |
| 108 | let listbox = this.getListbox(); |
| 109 | if (listbox) { |
| 110 | act(() => listbox.focus()); |
| 111 | await this.user.keyboard('[Escape]'); |
| 112 | } |
| 113 | |
| 114 | await waitFor(() => { |
| 115 | if (document.activeElement !== this._trigger) { |
| 116 | throw new Error( |
| 117 | `Expected the document.activeElement after closing the select dropdown to be the select component trigger but got ${document.activeElement}` |
| 118 | ); |
| 119 | } else { |
| 120 | return true; |
| 121 | } |
| 122 | }); |
| 123 | |
| 124 | if (listbox && document.contains(listbox)) { |
| 125 | throw new Error( |
| 126 | 'Expected the select element listbox to not be in the document after closing the dropdown.' |
| 127 | ); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Returns a option matching the specified index or text content. |
nothing calls this directly
no test coverage detected