* Returns a option matching the specified index or text content.
(opts: {indexOrText: number | string})
| 164 | * Returns a option matching the specified index or text content. |
| 165 | */ |
| 166 | findOption(opts: {indexOrText: number | string}): HTMLElement { |
| 167 | let {indexOrText} = opts; |
| 168 | |
| 169 | let option; |
| 170 | let options = this.getOptions(); |
| 171 | let menu = this.getMenu(); |
| 172 | |
| 173 | if (typeof indexOrText === 'number') { |
| 174 | option = options[indexOrText]; |
| 175 | } else if (typeof indexOrText === 'string' && menu != null) { |
| 176 | option = within(menu!) |
| 177 | .getByText(indexOrText) |
| 178 | .closest('[role=menuitem], [role=menuitemradio], [role=menuitemcheckbox]')! as HTMLElement; |
| 179 | } |
| 180 | |
| 181 | return option; |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * Toggles the selection of the desired menu option if possible. Defaults to using the interaction |
no test coverage detected