generated from RedHatInsights/frontend-starter-app
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
133 additions
and
84 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
import type { DeepPartial, Reducer, ReducersMapObject, Store } from 'redux'; | ||
import { applyMiddleware, combineReducers, createStore } from 'redux'; | ||
import { configureStore as createStore } from '@reduxjs/toolkit'; | ||
import type { Reducer, ReducersMapObject, Store } from 'redux'; | ||
import { combineReducers } from 'redux'; | ||
|
||
import type { RootState } from './rootReducer'; | ||
import { middlewares } from './store'; | ||
import { middleware } from './store'; | ||
|
||
type MockReducer<S> = ReducersMapObject<S, any> | Reducer<S>; | ||
|
||
export function createMockStoreCreator<S>(reducer: MockReducer<S>) { | ||
const rootReducer = typeof reducer === 'object' ? combineReducers(reducer) : reducer; | ||
|
||
return (initialState?: DeepPartial<S>): Store<RootState, any> => { | ||
return createStore<RootState, any, any, any>(rootReducer as any, initialState, applyMiddleware(...middlewares)); | ||
return (initialState?: Partial<S>): Store<RootState, any> => { | ||
return createStore<RootState, any, any, any>({ | ||
middleware, | ||
preloadedState: initialState as any, | ||
reducer: rootReducer as any, | ||
}); | ||
}; | ||
} |
Oops, something went wrong.