Skip to content

Commit c51406d

Browse files
committed
Apply normalizer treatment to queryAllByDisplayValue
1 parent c441145 commit c51406d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Diff for: src/__tests__/text-matchers.js

+4
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ cases(
256256
dom: `<input value="User ${LRM}name" />`,
257257
queryFn: 'queryAllByValue',
258258
},
259+
queryAllByDisplayValue: {
260+
dom: `<input value="User ${LRM}name" />`,
261+
queryFn: 'queryAllByDisplayValue',
262+
},
259263
queryAllByRole: {
260264
dom: `<input role="User ${LRM}name" />`,
261265
queryFn: 'queryAllByRole',

Diff for: src/queries.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -187,21 +187,21 @@ function queryByAltText(...args) {
187187
function queryAllByDisplayValue(
188188
container,
189189
value,
190-
{exact = true, collapseWhitespace = true, trim = true} = {},
190+
{exact = true, collapseWhitespace, trim, normalizer} = {},
191191
) {
192192
const matcher = exact ? matches : fuzzyMatches
193-
const matchOpts = {collapseWhitespace, trim}
193+
const matchNormalizer = makeNormalizer({collapseWhitespace, trim, normalizer})
194194
return Array.from(container.querySelectorAll(`input,textarea,select`)).filter(
195195
node => {
196196
if (node.tagName === 'SELECT') {
197197
const selectedOptions = Array.from(node.options).filter(
198198
option => option.selected,
199199
)
200200
return selectedOptions.some(optionNode =>
201-
matcher(getNodeText(optionNode), optionNode, value, matchOpts),
201+
matcher(getNodeText(optionNode), optionNode, value, matchNormalizer),
202202
)
203203
} else {
204-
return matcher(node.value, node, value, matchOpts)
204+
return matcher(node.value, node, value, matchNormalizer)
205205
}
206206
},
207207
)

0 commit comments

Comments
 (0)