1+ import type { QuerySubState } from '@internal/query/core/apiState'
2+ import type { Post } from '@internal/query/tests/mocks/handlers'
3+ import { posts } from '@internal/query/tests/mocks/handlers'
4+ import { actionsReducer , setupApiStore } from '@internal/tests/utils/helpers'
15import type { SerializedError } from '@reduxjs/toolkit'
26import { configureStore } from '@reduxjs/toolkit'
37import type { BaseQueryFn , FetchBaseQueryError } from '@reduxjs/toolkit/query'
48import { createApi , fetchBaseQuery } from '@reduxjs/toolkit/query'
5- import type { Post } from './mocks/handlers'
6- import { posts } from './mocks/handlers'
7- import { actionsReducer , setupApiStore } from '../../tests/utils/helpers'
8- import type { QuerySubState } from '@reduxjs/toolkit/dist/query/core/apiState'
99
1010describe ( 'queryFn base implementation tests' , ( ) => {
1111 const baseQuery : BaseQueryFn < string , { wrappedByBaseQuery : string } , string > =
1212 vi . fn ( ( arg : string ) =>
1313 arg . includes ( 'withErrorQuery' )
1414 ? { error : `cut${ arg } ` }
15- : { data : { wrappedByBaseQuery : arg } }
15+ : { data : { wrappedByBaseQuery : arg } } ,
1616 )
1717
1818 const api = createApi ( {
@@ -193,27 +193,27 @@ describe('queryFn base implementation tests', () => {
193193 endpointName . includes ( 'Throw' )
194194 ? `An unhandled error occurred processing a request for the endpoint "${ endpointName } ".
195195 In the case of an unhandled error, no tags will be "provided" or "invalidated". [Error: resultFrom(${ endpointName } )]`
196- : ''
196+ : '' ,
197197 )
198198 if ( expectedResult === 'data' ) {
199199 expect ( result ) . toEqual (
200200 expect . objectContaining ( {
201201 data : `resultFrom(${ endpointName } )` ,
202- } )
202+ } ) ,
203203 )
204204 } else if ( expectedResult === 'error' ) {
205205 expect ( result ) . toEqual (
206206 expect . objectContaining ( {
207207 error : `resultFrom(${ endpointName } )` ,
208- } )
208+ } ) ,
209209 )
210210 } else {
211211 expect ( result ) . toEqual (
212212 expect . objectContaining ( {
213213 error : expect . objectContaining ( {
214214 message : `resultFrom(${ endpointName } )` ,
215215 } ) ,
216- } )
216+ } ) ,
217217 )
218218 }
219219 } )
@@ -241,28 +241,28 @@ describe('queryFn base implementation tests', () => {
241241 endpointName . includes ( 'Throw' )
242242 ? `An unhandled error occurred processing a request for the endpoint "${ endpointName } ".
243243 In the case of an unhandled error, no tags will be "provided" or "invalidated". [Error: resultFrom(${ endpointName } )]`
244- : ''
244+ : '' ,
245245 )
246246
247247 if ( expectedResult === 'data' ) {
248248 expect ( result ) . toEqual (
249249 expect . objectContaining ( {
250250 data : `resultFrom(${ endpointName } )` ,
251- } )
251+ } ) ,
252252 )
253253 } else if ( expectedResult === 'error' ) {
254254 expect ( result ) . toEqual (
255255 expect . objectContaining ( {
256256 error : `resultFrom(${ endpointName } )` ,
257- } )
257+ } ) ,
258258 )
259259 } else {
260260 expect ( result ) . toEqual (
261261 expect . objectContaining ( {
262262 error : expect . objectContaining ( {
263263 message : `resultFrom(${ endpointName } )` ,
264264 } ) ,
265- } )
265+ } ) ,
266266 )
267267 }
268268 } )
@@ -275,12 +275,12 @@ describe('queryFn base implementation tests', () => {
275275 result = await store . dispatch ( thunk )
276276 } ) . toHaveConsoleOutput (
277277 `An unhandled error occurred processing a request for the endpoint "withNeither".
278- In the case of an unhandled error, no tags will be "provided" or "invalidated". [TypeError: endpointDefinition.queryFn is not a function]`
278+ In the case of an unhandled error, no tags will be "provided" or "invalidated". [TypeError: endpointDefinition.queryFn is not a function]` ,
279279 )
280280 expect ( result ! . error ) . toEqual (
281281 expect . objectContaining ( {
282282 message : 'endpointDefinition.queryFn is not a function' ,
283- } )
283+ } ) ,
284284 )
285285 }
286286 {
@@ -293,12 +293,12 @@ describe('queryFn base implementation tests', () => {
293293 result = await store . dispatch ( thunk )
294294 } ) . toHaveConsoleOutput (
295295 `An unhandled error occurred processing a request for the endpoint "mutationWithNeither".
296- In the case of an unhandled error, no tags will be "provided" or "invalidated". [TypeError: endpointDefinition.queryFn is not a function]`
296+ In the case of an unhandled error, no tags will be "provided" or "invalidated". [TypeError: endpointDefinition.queryFn is not a function]` ,
297297 )
298298 expect ( ( result as any ) . error ) . toEqual (
299299 expect . objectContaining ( {
300300 message : 'endpointDefinition.queryFn is not a function' ,
301- } )
301+ } ) ,
302302 )
303303 }
304304 } )
@@ -372,14 +372,14 @@ describe('usage scenario tests', () => {
372372
373373 it ( 'can chain multiple queries together' , async ( ) => {
374374 const result = await storeRef . store . dispatch (
375- api . endpoints . getRandomUser . initiate ( )
375+ api . endpoints . getRandomUser . initiate ( ) ,
376376 )
377377 expect ( result . data ) . toEqual ( posts [ 1 ] )
378378 } )
379379
380380 it ( 'can wrap a service like Firebase' , async ( ) => {
381381 const result = await storeRef . store . dispatch (
382- api . endpoints . getFirebaseUser . initiate ( 1 )
382+ api . endpoints . getFirebaseUser . initiate ( 1 ) ,
383383 )
384384 expect ( result . data ) . toEqual ( mockData )
385385 } )
@@ -388,7 +388,7 @@ describe('usage scenario tests', () => {
388388 let result : QuerySubState < any >
389389 await expect ( async ( ) => {
390390 result = await storeRef . store . dispatch (
391- api . endpoints . getMissingFirebaseUser . initiate ( 1 )
391+ api . endpoints . getMissingFirebaseUser . initiate ( 1 ) ,
392392 )
393393 } )
394394 . toHaveConsoleOutput ( `An unhandled error occurred processing a request for the endpoint "getMissingFirebaseUser".
@@ -399,7 +399,7 @@ describe('usage scenario tests', () => {
399399 expect . objectContaining ( {
400400 message : 'Missing user' ,
401401 name : 'Error' ,
402- } )
402+ } ) ,
403403 )
404404 } )
405405} )
0 commit comments