Skip to content

Commit

Permalink
Fix OverrideResultType imports in test files
Browse files Browse the repository at this point in the history
  • Loading branch information
aryaemami59 committed Jan 29, 2024
1 parent 5a43739 commit 3418c5a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
6 changes: 2 additions & 4 deletions packages/toolkit/src/query/tests/createApi.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ import type { SerializedError } from '@reduxjs/toolkit'
import { configureStore } from '@reduxjs/toolkit'
import type {
DefinitionsFromApi,
OverrideResultType,
TagTypesFromApi,
} from '@reduxjs/toolkit/dist/query/endpointDefinitions'
import type {
FetchBaseQueryError,
MutationDefinition,
OverrideResultType,
QueryDefinition,
TagDescription,
TagTypesFromApi,
} from '@reduxjs/toolkit/query'
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query'

Expand Down
21 changes: 9 additions & 12 deletions packages/toolkit/src/query/tests/createApi.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import { server } from '@internal/query/tests/mocks/server'
import {
getSerializedHeaders,
setupApiStore,
} from '@internal/tests/utils/helpers'
import { configureStore, createAction, createReducer } from '@reduxjs/toolkit'
import type {
DefinitionsFromApi,
FetchBaseQueryMeta,
OverrideResultType,
SerializeQueryArgs,
TagTypesFromApi,
} from '@reduxjs/toolkit/query'
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query'
import type { MockInstance } from 'vitest'

import type {
DefinitionsFromApi,
OverrideResultType,
TagTypesFromApi,
} from '@reduxjs/toolkit/dist/query/endpointDefinitions'
import { server } from '@internal/query/tests/mocks/server'
import {
getSerializedHeaders,
setupApiStore,
} from '@internal/tests/utils/helpers'
import { HttpResponse, delay, http } from 'msw'
import nodeFetch from 'node-fetch'
import type { MockInstance } from 'vitest'

beforeAll(() => {
vi.stubEnv('NODE_ENV', 'development')
Expand Down
14 changes: 7 additions & 7 deletions packages/toolkit/src/query/tests/invalidation.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { TagDescription } from '@reduxjs/toolkit/dist/query/endpointDefinitions'
import type { TagDescription } from '@reduxjs/toolkit/query'
import { createApi, fakeBaseQuery } from '@reduxjs/toolkit/query'
import { waitFor } from '@testing-library/react'
import { delay } from 'msw'
Expand All @@ -13,7 +13,7 @@ const tagTypes = [
'dog',
'giraffe',
] as const
type TagTypes = typeof tagTypes[number]
type TagTypes = (typeof tagTypes)[number]
type Tags = TagDescription<TagTypes>[]

/** providesTags, invalidatesTags, shouldInvalidate */
Expand Down Expand Up @@ -103,23 +103,23 @@ test.each(caseMatrix)(
}),
}),
undefined,
{ withoutTestLifecycles: true }
{ withoutTestLifecycles: true },
)

store.dispatch(providing.initiate())
store.dispatch(unrelated.initiate())
expect(queryCount).toBe(1)
await waitFor(() => {
expect(api.endpoints.providing.select()(store.getState()).status).toBe(
'fulfilled'
'fulfilled',
)
expect(api.endpoints.unrelated.select()(store.getState()).status).toBe(
'fulfilled'
'fulfilled',
)
})
const toInvalidate = api.util.selectInvalidatedBy(
store.getState(),
invalidatesTags
invalidatesTags,
)

if (shouldInvalidate) {
Expand All @@ -138,5 +138,5 @@ test.each(caseMatrix)(
expect(queryCount).toBe(1)
await delay(2)
expect(queryCount).toBe(shouldInvalidate ? 2 : 1)
}
},
)

0 comments on commit 3418c5a

Please sign in to comment.