* Returns a option matching the specified index or text content.
(opts: {indexOrText: number | string})
| 132 | * Returns a option matching the specified index or text content. |
| 133 | */ |
| 134 | findOption(opts: {indexOrText: number | string}): HTMLElement { |
| 135 | let {indexOrText} = opts; |
| 136 | |
| 137 | let option; |
| 138 | let options = this.getOptions(); |
| 139 | let listbox = this.getListbox(); |
| 140 | |
| 141 | if (typeof indexOrText === 'number') { |
| 142 | option = options[indexOrText]; |
| 143 | } else if (typeof indexOrText === 'string' && listbox != null) { |
| 144 | option = within(listbox!).getByText(indexOrText).closest('[role=option]')! as HTMLElement; |
| 145 | } |
| 146 | |
| 147 | return option; |
| 148 | } |
| 149 | |
| 150 | private async keyboardNavigateToOption(opts: {option: HTMLElement}) { |
| 151 | let {option} = opts; |
no test coverage detected