Skip to content

Commit

Permalink
rename storeWithApi by defaultStore
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark committed May 8, 2023
1 parent fc84787 commit cc5324f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 24 deletions.
33 changes: 14 additions & 19 deletions superset-frontend/spec/helpers/testing-library.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ type Options = Omit<RenderOptions, 'queries'> & {
store?: Store;
};

export const storeWithApi = configureStore({
reducer: {
[api.reducerPath]: api.reducer,
},
middleware: getDefaultMiddleware =>
getDefaultMiddleware().concat(api.middleware),
devTools: false,
});
const createStore = (initialState: object = {}, reducers: object = {}) =>
configureStore({
preloadedState: initialState,
reducer: {
...reducers,
[api.reducerPath]: api.reducer,
},
middleware: getDefaultMiddleware =>
getDefaultMiddleware().concat(api.middleware),
devTools: false,
});

export const defaultStore = createStore();

export function createWrapper(options?: Options) {
const {
Expand All @@ -70,17 +75,7 @@ export function createWrapper(options?: Options) {

if (useRedux) {
const mockStore =
store ??
configureStore({
preloadedState: initialState,
devTools: false,
reducer: {
...(reducers || reducerIndex),
[api.reducerPath]: api.reducer,
},
middleware: getDefaultMiddleware =>
getDefaultMiddleware().concat(api.middleware),
});
store ?? createStore(initialState, reducers || reducerIndex);
result = <Provider store={mockStore}>{result}</Provider>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
render,
screen,
waitFor,
storeWithApi as store,
defaultStore as store,
} from 'spec/helpers/testing-library';
import userEvent from '@testing-library/user-event';
import { api } from 'src/hooks/apiResources/queryApi';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import sinon from 'sinon';
import { supersetTheme, ThemeProvider } from '@superset-ui/core';

import waitForComponentToPaint from 'spec/helpers/waitForComponentToPaint';
import { storeWithApi as store } from 'spec/helpers/testing-library';
import { defaultStore as store } from 'spec/helpers/testing-library';
import Modal from 'src/components/Modal';
import { DatasourceModal } from 'src/components/Datasource';
import DatasourceEditor from 'src/components/Datasource/DatasourceEditor';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
screen,
waitFor,
within,
storeWithApi as store,
defaultStore as store,
} from 'spec/helpers/testing-library';
import { api } from 'src/hooks/apiResources/queryApi';
import fetchMock from 'fetch-mock';
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/hooks/apiResources/schemas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import fetchMock from 'fetch-mock';
import { act, renderHook } from '@testing-library/react-hooks';
import {
createWrapper,
storeWithApi as store,
defaultStore as store,
} from 'spec/helpers/testing-library';
import { api } from 'src/hooks/apiResources/queryApi';
import { useSchemas } from './schemas';
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/hooks/apiResources/tables.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import fetchMock from 'fetch-mock';
import { act, renderHook } from '@testing-library/react-hooks';
import {
createWrapper,
storeWithApi as store,
defaultStore as store,
} from 'spec/helpers/testing-library';
import { api } from 'src/hooks/apiResources/queryApi';
import { useTables } from './tables';
Expand Down

0 comments on commit cc5324f

Please sign in to comment.