(
container,
value,
{exact = true, collapseWhitespace, trim, normalizer} = {},
)
| 15 | } from './all-utils' |
| 16 | |
| 17 | const queryAllByDisplayValue: AllByBoundAttribute = ( |
| 18 | container, |
| 19 | value, |
| 20 | {exact = true, collapseWhitespace, trim, normalizer} = {}, |
| 21 | ) => { |
| 22 | checkContainerType(container) |
| 23 | const matcher = exact ? matches : fuzzyMatches |
| 24 | const matchNormalizer = makeNormalizer({collapseWhitespace, trim, normalizer}) |
| 25 | return Array.from( |
| 26 | container.querySelectorAll<HTMLElement>(`input,textarea,select`), |
| 27 | ).filter(node => { |
| 28 | if (node.tagName === 'SELECT') { |
| 29 | const selectedOptions = Array.from( |
| 30 | (node as HTMLSelectElement).options, |
| 31 | ).filter(option => option.selected) |
| 32 | return selectedOptions.some(optionNode => |
| 33 | matcher(getNodeText(optionNode), optionNode, value, matchNormalizer), |
| 34 | ) |
| 35 | } else { |
| 36 | return matcher( |
| 37 | (node as HTMLInputElement).value, |
| 38 | node, |
| 39 | value, |
| 40 | matchNormalizer, |
| 41 | ) |
| 42 | } |
| 43 | }) |
| 44 | } |
| 45 | |
| 46 | const getMultipleError: GetErrorFunction<[unknown]> = (c, value) => |
| 47 | `Found multiple elements with the display value: ${value}.` |
no test coverage detected