Skip to content

Commit

Permalink
Remove satisfies operators in queryFn.test.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
aryaemami59 committed Oct 14, 2024
1 parent dc0452d commit c23567d
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/toolkit/src/query/tests/queryFn.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,7 @@ describe('queryFn base implementation tests', () => {

const thunk = endpoint.initiate(endpointName)

const result = (await store.dispatch(thunk)) satisfies
| undefined
| QuerySubState<any>
const result: undefined | QuerySubState<any> = await store.dispatch(thunk)

if (endpointName.includes('Throw')) {
expect(consoleErrorSpy).toHaveBeenCalledOnce()
Expand Down Expand Up @@ -246,10 +244,10 @@ describe('queryFn base implementation tests', () => {

const thunk = endpoint.initiate(endpointName)

const result = (await store.dispatch(thunk)) satisfies
const result:
| undefined
| { data: string }
| { error: string | SerializedError }
| { error: string | SerializedError } = await store.dispatch(thunk)

if (endpointName.includes('Throw')) {
expect(consoleErrorSpy).toHaveBeenCalledOnce()
Expand Down Expand Up @@ -293,7 +291,7 @@ describe('queryFn base implementation tests', () => {
{
const thunk = withNeither.initiate('withNeither')

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

expect(consoleErrorSpy).toHaveBeenCalledOnce()

Expand All @@ -313,10 +311,10 @@ describe('queryFn base implementation tests', () => {
{
const thunk = mutationWithNeither.initiate('mutationWithNeither')

const result = (await store.dispatch(thunk)) satisfies
const result:
| undefined
| { data: string }
| { error: string | SerializedError }
| { error: string | SerializedError } = await store.dispatch(thunk)

expect(consoleErrorSpy).toHaveBeenCalledOnce()

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

if (!('error' in result)) {
expect.fail()
}

expect(result.error).toEqual(
expect.objectContaining({
message: 'endpointDefinition.queryFn is not a function',
Expand Down Expand Up @@ -419,9 +421,9 @@ describe('usage scenario tests', () => {
it('can wrap a service like Firebase and handle errors', async () => {
const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(noop)

const result = (await storeRef.store.dispatch(
const result: QuerySubState<any> = await storeRef.store.dispatch(
api.endpoints.getMissingFirebaseUser.initiate(1),
)) satisfies QuerySubState<any>
)

expect(consoleErrorSpy).toHaveBeenCalledOnce()

Expand Down

0 comments on commit c23567d

Please sign in to comment.