Skip to content

Commit 80d2308

Browse files
committed
Fix console spy related issues in queryFn.test.tsx
1 parent 6590cec commit 80d2308

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

packages/toolkit/src/query/tests/queryFn.test.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,10 @@ describe('queryFn base implementation tests', () => {
244244

245245
const thunk = endpoint.initiate(endpointName)
246246

247-
const result:
247+
const result = (await store.dispatch(thunk)) satisfies
248248
| undefined
249249
| { data: string }
250-
| { error: string | SerializedError } = await store.dispatch(thunk)
250+
| { error: string | SerializedError }
251251

252252
if (endpointName.includes('Throw')) {
253253
expect(consoleErrorSpy).toHaveBeenCalledOnce()
@@ -291,7 +291,7 @@ describe('queryFn base implementation tests', () => {
291291
{
292292
const thunk = withNeither.initiate('withNeither')
293293

294-
const result: QuerySubState<any> = await store.dispatch(thunk)
294+
const result = (await store.dispatch(thunk)) satisfies QuerySubState<any>
295295

296296
expect(consoleErrorSpy).toHaveBeenCalledOnce()
297297

@@ -311,10 +311,10 @@ describe('queryFn base implementation tests', () => {
311311
{
312312
const thunk = mutationWithNeither.initiate('mutationWithNeither')
313313

314-
const result:
314+
const result = (await store.dispatch(thunk)) satisfies
315315
| undefined
316316
| { data: string }
317-
| { error: string | SerializedError } = await store.dispatch(thunk)
317+
| { error: string | SerializedError }
318318

319319
expect(consoleErrorSpy).toHaveBeenCalledOnce()
320320

@@ -323,10 +323,6 @@ describe('queryFn base implementation tests', () => {
323323
TypeError('endpointDefinition.queryFn is not a function'),
324324
)
325325

326-
if (!('error' in result)) {
327-
expect.fail()
328-
}
329-
330326
expect(result.error).toEqual(
331327
expect.objectContaining({
332328
message: 'endpointDefinition.queryFn is not a function',
@@ -421,9 +417,9 @@ describe('usage scenario tests', () => {
421417
it('can wrap a service like Firebase and handle errors', async () => {
422418
const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(noop)
423419

424-
const result: QuerySubState<any> = await storeRef.store.dispatch(
420+
const result = (await storeRef.store.dispatch(
425421
api.endpoints.getMissingFirebaseUser.initiate(1),
426-
)
422+
)) satisfies QuerySubState<any>
427423

428424
expect(consoleErrorSpy).toHaveBeenCalledOnce()
429425

0 commit comments

Comments
 (0)