lml-main
Version:
This is now a mono repository published into many standalone packages.
37 lines (32 loc) • 1.15 kB
text/typescript
import { createCosmoReduxStore, CosmoReduxStoreConfig } from '../src'
import { combineReducers } from 'redux'
import { combineEpics } from 'redux-observable'
// a mock of window.localStorage
const mockLocalStorage: Storage = {
length: 0,
clear: () => {},
getItem: (key: string) => null,
key: (index: number) => null,
removeItem: (key: string) => {},
setItem: (key: string, data: string) => {},
}
it('should create a new store', () => {
const exampleState = { foo: 'bar' }
const REDUCER_KEY = 'test'
const testReducer = (state: any, action: any) => exampleState
const rootReducer = combineReducers({ [REDUCER_KEY]: testReducer })
const epicDependencies = {}
const config: CosmoReduxStoreConfig = {
storage: mockLocalStorage,
rootReducer,
rootEpic: combineEpics(),
epicDependencies,
localStoragePaths: [],
localStorageKey: 'cosmo',
disableReduxLogger: true,
disableReduxDevtools: true,
}
const store = createCosmoReduxStore(config)
const state = store.getState()
expect(state[REDUCER_KEY]).toEqual(exampleState)
})