-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* eslint-disable import/no-named-as-default-member */ | ||
import { createStore as createReduxStore } from 'redux'; | ||
import dynoStore, { createStore, reloadStore, injectReducers } from './dynoStore'; | ||
|
||
describe('Dyno Store', () => { | ||
it('should have main methods', () => { | ||
expect(dynoStore).toHaveProperty('createStore'); | ||
expect(dynoStore).toHaveProperty('reloadStore'); | ||
expect(dynoStore).toHaveProperty('injectReducers'); | ||
expect(dynoStore).toHaveProperty('withStoreModule'); | ||
}); | ||
|
||
it('should create and return a Redux store', () => { | ||
const reduxStore = createReduxStore(() => ({})); | ||
const store = createStore(); | ||
expect(JSON.stringify(store, null)).toEqual(JSON.stringify(reduxStore, null)); | ||
}); | ||
|
||
it('should trigger store\'s "dispatch" when reloading the store', () => { | ||
const store = createStore(); | ||
const mockDispatch = jest.spyOn(store, 'dispatch'); | ||
reloadStore(); | ||
expect(mockDispatch).toHaveBeenCalledTimes(1); | ||
expect(mockDispatch).toHaveBeenCalledWith({ type: '@@DYNO_STORE/RELOAD' }); | ||
}); | ||
|
||
it('should add reducer and reload the store', () => { | ||
const store = createStore(); | ||
const reducer = { INIT_DYNO_STATE: (): {} => ({}) }; | ||
const mockDispatch = jest.spyOn(store, 'dispatch'); | ||
injectReducers(reducer); | ||
expect(mockDispatch).toHaveBeenCalledTimes(1); | ||
expect(mockDispatch).toHaveBeenCalledWith({ type: '@@DYNO_STORE/RELOAD' }); | ||
}); | ||
}); |