diff --git a/src/__tests__/text-matchers.js b/src/__tests__/text-matchers.js index 4ff6fcc4..7cbd6924 100644 --- a/src/__tests__/text-matchers.js +++ b/src/__tests__/text-matchers.js @@ -256,6 +256,10 @@ cases( dom: ``, queryFn: 'queryAllByValue', }, + queryAllByDisplayValue: { + dom: ``, + queryFn: 'queryAllByDisplayValue', + }, queryAllByRole: { dom: ``, queryFn: 'queryAllByRole', diff --git a/src/queries.js b/src/queries.js index 2ee31ae2..e5393222 100644 --- a/src/queries.js +++ b/src/queries.js @@ -187,10 +187,10 @@ function queryByAltText(...args) { function queryAllByDisplayValue( container, value, - {exact = true, collapseWhitespace = true, trim = true} = {}, + {exact = true, collapseWhitespace, trim, normalizer} = {}, ) { const matcher = exact ? matches : fuzzyMatches - const matchOpts = {collapseWhitespace, trim} + const matchNormalizer = makeNormalizer({collapseWhitespace, trim, normalizer}) return Array.from(container.querySelectorAll(`input,textarea,select`)).filter( node => { if (node.tagName === 'SELECT') { @@ -198,10 +198,10 @@ function queryAllByDisplayValue( option => option.selected, ) return selectedOptions.some(optionNode => - matcher(getNodeText(optionNode), optionNode, value, matchOpts), + matcher(getNodeText(optionNode), optionNode, value, matchNormalizer), ) } else { - return matcher(node.value, node, value, matchOpts) + return matcher(node.value, node, value, matchNormalizer) } }, )