@@ -100,49 +100,47 @@ function makeFindQuery(getter) {
100
100
}
101
101
}
102
102
103
- const wrapSingleQueryWithSuggestion = ( query , queryAllByName , variant ) => (
104
- container ,
105
- ...args
106
- ) => {
107
- const element = query ( container , ... args )
108
- const [ { suggest = getConfig ( ) . throwSuggestions } = { } ] = args . slice ( - 1 )
109
- if ( element && suggest ) {
110
- const suggestion = getSuggestedQuery ( element , variant )
111
- if ( suggestion && ! queryAllByName . endsWith ( suggestion . queryName ) ) {
112
- throw getSuggestionError ( suggestion . toString ( ) , container )
103
+ const wrapSingleQueryWithSuggestion =
104
+ ( query , queryAllByName , variant ) =>
105
+ ( container , ...args ) => {
106
+ const element = query ( container , ... args )
107
+ const [ { suggest = getConfig ( ) . throwSuggestions } = { } ] = args . slice ( - 1 )
108
+ if ( element && suggest ) {
109
+ const suggestion = getSuggestedQuery ( element , variant )
110
+ if ( suggestion && ! queryAllByName . endsWith ( suggestion . queryName ) ) {
111
+ throw getSuggestionError ( suggestion . toString ( ) , container )
112
+ }
113
113
}
114
- }
115
114
116
- return element
117
- }
115
+ return element
116
+ }
118
117
119
- const wrapAllByQueryWithSuggestion = ( query , queryAllByName , variant ) => (
120
- container ,
121
- ...args
122
- ) => {
123
- const els = query ( container , ... args )
124
-
125
- const [ { suggest = getConfig ( ) . throwSuggestions } = { } ] = args . slice ( - 1 )
126
- if ( els . length && suggest ) {
127
- // get a unique list of all suggestion messages. We are only going to make a suggestion if
128
- // all the suggestions are the same
129
- const uniqueSuggestionMessages = [
130
- ... new Set (
131
- els . map ( element => getSuggestedQuery ( element , variant ) ?. toString ( ) ) ,
132
- ) ,
133
- ]
134
-
135
- if (
136
- // only want to suggest if all the els have the same suggestion.
137
- uniqueSuggestionMessages . length === 1 &&
138
- ! queryAllByName . endsWith ( getSuggestedQuery ( els [ 0 ] , variant ) . queryName )
139
- ) {
140
- throw getSuggestionError ( uniqueSuggestionMessages [ 0 ] , container )
118
+ const wrapAllByQueryWithSuggestion =
119
+ ( query , queryAllByName , variant ) =>
120
+ ( container , ...args ) => {
121
+ const els = query ( container , ... args )
122
+
123
+ const [ { suggest = getConfig ( ) . throwSuggestions } = { } ] = args . slice ( - 1 )
124
+ if ( els . length && suggest ) {
125
+ // get a unique list of all suggestion messages. We are only going to make a suggestion if
126
+ // all the suggestions are the same
127
+ const uniqueSuggestionMessages = [
128
+ ... new Set (
129
+ els . map ( element => getSuggestedQuery ( element , variant ) ?. toString ( ) ) ,
130
+ ) ,
131
+ ]
132
+
133
+ if (
134
+ // only want to suggest if all the els have the same suggestion.
135
+ uniqueSuggestionMessages . length === 1 &&
136
+ ! queryAllByName . endsWith ( getSuggestedQuery ( els [ 0 ] , variant ) . queryName )
137
+ ) {
138
+ throw getSuggestionError ( uniqueSuggestionMessages [ 0 ] , container )
139
+ }
141
140
}
142
- }
143
141
144
- return els
145
- }
142
+ return els
143
+ }
146
144
147
145
function buildQueries ( queryAllBy , getMultipleError , getMissingError ) {
148
146
const queryBy = wrapSingleQueryWithSuggestion (
0 commit comments