#473 Added listbox options support in selectOptions

Merged luistak

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 1 of 3 files from the diff.

@@ -1,6 +1,7 @@
Loading
1 1
import {createEvent, getConfig, fireEvent} from '@testing-library/dom'
2 2
import {click} from './click'
3 3
import {focus} from './focus'
4 +
import {hover, unhover} from './hover'
4 5
5 6
function selectOptionsBase(newValue, select, values, init) {
6 7
  if (!newValue && !select.multiple) {
@@ -18,7 +19,9 @@
Loading
18 19
      if (allOptions.includes(val)) {
19 20
        return val
20 21
      } else {
21 -
        const matchingOption = allOptions.find(o => o.value === val)
22 +
        const matchingOption = allOptions.find(
23 +
          o => o.value === val || o.innerHTML === val,
24 +
        )
22 25
        if (matchingOption) {
23 26
          return matchingOption
24 27
        } else {
@@ -61,17 +64,25 @@
Loading
61 64
  }
62 65
63 66
  function selectOption(option) {
64 -
    option.selected = newValue
65 -
    fireEvent(
66 -
      select,
67 -
      createEvent('input', select, {
68 -
        bubbles: true,
69 -
        cancelable: false,
70 -
        composed: true,
71 -
        ...init,
72 -
      }),
73 -
    )
74 -
    fireEvent.change(select, init)
67 +
    if (option.getAttribute('role') === 'option') {
68 +
      option?.setAttribute?.('aria-selected', newValue)
69 +
70 +
      hover(option, init)
71 +
      click(option, init)
72 +
      unhover(option, init)
73 +
    } else {
74 +
      option.selected = newValue
75 +
      fireEvent(
76 +
        select,
77 +
        createEvent('input', select, {
78 +
          bubbles: true,
79 +
          cancelable: false,
80 +
          composed: true,
81 +
          ...init,
82 +
        }),
83 +
      )
84 +
      fireEvent.change(select, init)
85 +
    }
75 86
  }
76 87
}
77 88

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
src 100.00%
Project Totals (12 files) 100.00%
Loading