MCPcopy Index your code
hub / github.com/testing-library/dom-testing-library / wrapSingleQueryWithSuggestion

Function wrapSingleQueryWithSuggestion

src/query-helpers.ts:143–164  ·  view source on GitHub ↗
(
    query: (container: HTMLElement, ...args: Arguments) => HTMLElement | null,
    queryAllByName: string,
    variant: Variant,
  )

Source from the content-addressed store, hash-verified

141
142const wrapSingleQueryWithSuggestion =
143 <Arguments extends [...unknown[], WithSuggest]>(
144 query: (container: HTMLElement, ...args: Arguments) => HTMLElement | null,
145 queryAllByName: string,
146 variant: Variant,
147 ) =>
148 (container: HTMLElement, ...args: Arguments) => {
149 const element = query(container, ...args)
150 const [{suggest = getConfig().throwSuggestions} = {}] = args.slice(-1) as [
151 WithSuggest,
152 ]
153 if (element && suggest) {
154 const suggestion = getSuggestedQuery(element, variant)
155 if (
156 suggestion &&
157 !queryAllByName.endsWith(suggestion.queryName as string)
158 ) {
159 throw getSuggestionError(suggestion.toString(), container)
160 }
161 }
162
163 return element
164 }
165
166const wrapAllByQueryWithSuggestion =
167 <

Callers 2

buildQueriesFunction · 0.85
label-text.tsFile · 0.85

Calls 4

getConfigFunction · 0.90
getSuggestedQueryFunction · 0.90
getSuggestionErrorFunction · 0.85
toStringMethod · 0.80

Tested by

no test coverage detected