From 77511c32b3dab0a8ceb223e899e42182f64106da Mon Sep 17 00:00:00 2001 From: Arya Emami Date: Mon, 29 Jan 2024 06:18:35 -0600 Subject: [PATCH] Replace `dist` imports with `@internal` imports --- .../src/query/tests/buildHooks.test.tsx | 4 +- .../toolkit/src/query/tests/queryFn.test.tsx | 42 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/packages/toolkit/src/query/tests/buildHooks.test.tsx b/packages/toolkit/src/query/tests/buildHooks.test.tsx index bee8401b0d..868cd6647a 100644 --- a/packages/toolkit/src/query/tests/buildHooks.test.tsx +++ b/packages/toolkit/src/query/tests/buildHooks.test.tsx @@ -1,4 +1,6 @@ +import type { SubscriptionOptions } from '@internal/query/core/apiState' import type { SubscriptionSelectors } from '@internal/query/core/buildMiddleware/types' +import { server } from '@internal/query/tests/mocks/server' import { countObjectKeys } from '@internal/query/utils/countObjectKeys' import { actionsReducer, @@ -13,7 +15,6 @@ import { createListenerMiddleware, createSlice, } from '@reduxjs/toolkit' -import type { SubscriptionOptions } from '@reduxjs/toolkit/dist/query/core/apiState' import { QueryStatus, createApi, @@ -32,7 +33,6 @@ import userEvent from '@testing-library/user-event' import { HttpResponse, http } from 'msw' import { useEffect, useState } from 'react' import type { MockInstance } from 'vitest' -import { server } from './mocks/server' // Just setup a temporary in-memory counter for tests that `getIncrementedAmount`. // This can be used to test how many renders happen due to data changes or diff --git a/packages/toolkit/src/query/tests/queryFn.test.tsx b/packages/toolkit/src/query/tests/queryFn.test.tsx index 0114f7cff2..4b292f9983 100644 --- a/packages/toolkit/src/query/tests/queryFn.test.tsx +++ b/packages/toolkit/src/query/tests/queryFn.test.tsx @@ -1,18 +1,18 @@ +import type { QuerySubState } from '@internal/query/core/apiState' +import type { Post } from '@internal/query/tests/mocks/handlers' +import { posts } from '@internal/query/tests/mocks/handlers' +import { actionsReducer, setupApiStore } from '@internal/tests/utils/helpers' import type { SerializedError } from '@reduxjs/toolkit' import { configureStore } from '@reduxjs/toolkit' import type { BaseQueryFn, FetchBaseQueryError } from '@reduxjs/toolkit/query' import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query' -import type { Post } from './mocks/handlers' -import { posts } from './mocks/handlers' -import { actionsReducer, setupApiStore } from '../../tests/utils/helpers' -import type { QuerySubState } from '@reduxjs/toolkit/dist/query/core/apiState' describe('queryFn base implementation tests', () => { const baseQuery: BaseQueryFn = vi.fn((arg: string) => arg.includes('withErrorQuery') ? { error: `cut${arg}` } - : { data: { wrappedByBaseQuery: arg } } + : { data: { wrappedByBaseQuery: arg } }, ) const api = createApi({ @@ -193,19 +193,19 @@ describe('queryFn base implementation tests', () => { endpointName.includes('Throw') ? `An unhandled error occurred processing a request for the endpoint "${endpointName}". In the case of an unhandled error, no tags will be "provided" or "invalidated". [Error: resultFrom(${endpointName})]` - : '' + : '', ) if (expectedResult === 'data') { expect(result).toEqual( expect.objectContaining({ data: `resultFrom(${endpointName})`, - }) + }), ) } else if (expectedResult === 'error') { expect(result).toEqual( expect.objectContaining({ error: `resultFrom(${endpointName})`, - }) + }), ) } else { expect(result).toEqual( @@ -213,7 +213,7 @@ describe('queryFn base implementation tests', () => { error: expect.objectContaining({ message: `resultFrom(${endpointName})`, }), - }) + }), ) } }) @@ -241,20 +241,20 @@ describe('queryFn base implementation tests', () => { endpointName.includes('Throw') ? `An unhandled error occurred processing a request for the endpoint "${endpointName}". In the case of an unhandled error, no tags will be "provided" or "invalidated". [Error: resultFrom(${endpointName})]` - : '' + : '', ) if (expectedResult === 'data') { expect(result).toEqual( expect.objectContaining({ data: `resultFrom(${endpointName})`, - }) + }), ) } else if (expectedResult === 'error') { expect(result).toEqual( expect.objectContaining({ error: `resultFrom(${endpointName})`, - }) + }), ) } else { expect(result).toEqual( @@ -262,7 +262,7 @@ describe('queryFn base implementation tests', () => { error: expect.objectContaining({ message: `resultFrom(${endpointName})`, }), - }) + }), ) } }) @@ -275,12 +275,12 @@ describe('queryFn base implementation tests', () => { result = await store.dispatch(thunk) }).toHaveConsoleOutput( `An unhandled error occurred processing a request for the endpoint "withNeither". - In the case of an unhandled error, no tags will be "provided" or "invalidated". [TypeError: endpointDefinition.queryFn is not a function]` + In the case of an unhandled error, no tags will be "provided" or "invalidated". [TypeError: endpointDefinition.queryFn is not a function]`, ) expect(result!.error).toEqual( expect.objectContaining({ message: 'endpointDefinition.queryFn is not a function', - }) + }), ) } { @@ -293,12 +293,12 @@ describe('queryFn base implementation tests', () => { result = await store.dispatch(thunk) }).toHaveConsoleOutput( `An unhandled error occurred processing a request for the endpoint "mutationWithNeither". - In the case of an unhandled error, no tags will be "provided" or "invalidated". [TypeError: endpointDefinition.queryFn is not a function]` + In the case of an unhandled error, no tags will be "provided" or "invalidated". [TypeError: endpointDefinition.queryFn is not a function]`, ) expect((result as any).error).toEqual( expect.objectContaining({ message: 'endpointDefinition.queryFn is not a function', - }) + }), ) } }) @@ -372,14 +372,14 @@ describe('usage scenario tests', () => { it('can chain multiple queries together', async () => { const result = await storeRef.store.dispatch( - api.endpoints.getRandomUser.initiate() + api.endpoints.getRandomUser.initiate(), ) expect(result.data).toEqual(posts[1]) }) it('can wrap a service like Firebase', async () => { const result = await storeRef.store.dispatch( - api.endpoints.getFirebaseUser.initiate(1) + api.endpoints.getFirebaseUser.initiate(1), ) expect(result.data).toEqual(mockData) }) @@ -388,7 +388,7 @@ describe('usage scenario tests', () => { let result: QuerySubState await expect(async () => { result = await storeRef.store.dispatch( - api.endpoints.getMissingFirebaseUser.initiate(1) + api.endpoints.getMissingFirebaseUser.initiate(1), ) }) .toHaveConsoleOutput(`An unhandled error occurred processing a request for the endpoint "getMissingFirebaseUser". @@ -399,7 +399,7 @@ describe('usage scenario tests', () => { expect.objectContaining({ message: 'Missing user', name: 'Error', - }) + }), ) }) })