* Opens the select. Defaults to using the interaction type set on the select tester.
(opts: SelectOpenOpts = {})
| 71 | * Opens the select. Defaults to using the interaction type set on the select tester. |
| 72 | */ |
| 73 | async open(opts: SelectOpenOpts = {}): Promise<void> { |
| 74 | let {interactionType = this._interactionType} = opts; |
| 75 | let trigger = this.getTrigger(); |
| 76 | let isDisabled = trigger.hasAttribute('disabled'); |
| 77 | |
| 78 | if (interactionType === 'mouse') { |
| 79 | await this.user.click(this._trigger); |
| 80 | } else if (interactionType === 'keyboard') { |
| 81 | act(() => trigger.focus()); |
| 82 | await this.user.keyboard('[Enter]'); |
| 83 | } else if (interactionType === 'touch') { |
| 84 | await this.user.pointer({target: this._trigger, keys: '[TouchA]'}); |
| 85 | } |
| 86 | |
| 87 | await waitFor(() => { |
| 88 | if (!isDisabled && trigger.getAttribute('aria-controls') == null) { |
| 89 | throw new Error('No aria-controls found on select element trigger.'); |
| 90 | } else { |
| 91 | return true; |
| 92 | } |
| 93 | }); |
| 94 | let listBoxId = trigger.getAttribute('aria-controls'); |
| 95 | await waitFor(() => { |
| 96 | if (!isDisabled && (!listBoxId || document.getElementById(listBoxId) == null)) { |
| 97 | throw new Error(`ListBox with id of ${listBoxId} not found in document.`); |
| 98 | } else { |
| 99 | return true; |
| 100 | } |
| 101 | }); |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Closes the select. |
no test coverage detected