Skip to content

Commit 91485d0

Browse files
committed
Update configureStore tests
1 parent b991089 commit 91485d0

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/configureStore.test.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@ import * as redux from 'redux'
33
import * as devtools from 'redux-devtools-extension'
44

55
import thunk from 'redux-thunk'
6+
import immutableStateInvariant from 'redux-immutable-state-invariant'
67

78
describe('getDefaultMiddleware', () => {
8-
it('returns an array with redux-thunk', () => {
9-
expect(getDefaultMiddleware()).toEqual([thunk])
9+
it('returns an array with only redux-thunk in production', () => {
10+
expect(getDefaultMiddleware(true)).toEqual([thunk])
11+
})
12+
13+
it('returns an array with additional middleware in development', () => {
14+
const middleware = getDefaultMiddleware(false);
15+
expect(middleware[middleware.length - 1]).toEqual(thunk)
16+
expect(middleware.length).toBeGreaterThan(1);
1017
})
1118
})
1219

@@ -16,14 +23,15 @@ describe('configureStore', () => {
1623
jest.spyOn(redux, 'compose')
1724
jest.spyOn(redux, 'createStore')
1825
jest.spyOn(devtools, 'composeWithDevTools')
26+
1927
function reducer() {}
2028

2129
beforeEach(() => jest.clearAllMocks())
2230

2331
describe('given a function reducer', () => {
2432
it('calls createStore with the reducer', () => {
2533
expect(configureStore({ reducer })).toBeInstanceOf(Object)
26-
expect(redux.applyMiddleware).toHaveBeenCalledWith(thunk)
34+
expect(redux.applyMiddleware).toHaveBeenCalled()
2735
expect(devtools.composeWithDevTools).toHaveBeenCalled()
2836
expect(redux.createStore).toHaveBeenCalledWith(
2937
reducer,
@@ -42,7 +50,7 @@ describe('configureStore', () => {
4250
}
4351
expect(configureStore({ reducer })).toBeInstanceOf(Object)
4452
expect(redux.combineReducers).toHaveBeenCalledWith(reducer)
45-
expect(redux.applyMiddleware).toHaveBeenCalledWith(thunk)
53+
expect(redux.applyMiddleware).toHaveBeenCalled()
4654
expect(devtools.composeWithDevTools).toHaveBeenCalled()
4755
expect(redux.createStore).toHaveBeenCalledWith(
4856
expect.any(Function),
@@ -94,7 +102,7 @@ describe('configureStore', () => {
94102
expect(configureStore({ devTools: false, reducer })).toBeInstanceOf(
95103
Object
96104
)
97-
expect(redux.applyMiddleware).toHaveBeenCalledWith(thunk)
105+
expect(redux.applyMiddleware).toHaveBeenCalled()
98106
expect(redux.compose).toHaveBeenCalled()
99107
expect(redux.createStore).toHaveBeenCalledWith(
100108
reducer,
@@ -107,7 +115,7 @@ describe('configureStore', () => {
107115
describe('given preloadedState', () => {
108116
it('calls createStore with preloadedState', () => {
109117
expect(configureStore({ reducer })).toBeInstanceOf(Object)
110-
expect(redux.applyMiddleware).toHaveBeenCalledWith(thunk)
118+
expect(redux.applyMiddleware).toHaveBeenCalled()
111119
expect(devtools.composeWithDevTools).toHaveBeenCalled()
112120
expect(redux.createStore).toHaveBeenCalledWith(
113121
reducer,
@@ -123,7 +131,7 @@ describe('configureStore', () => {
123131
expect(configureStore({ enhancers: [enhancer], reducer })).toBeInstanceOf(
124132
Object
125133
)
126-
expect(redux.applyMiddleware).toHaveBeenCalledWith(thunk)
134+
expect(redux.applyMiddleware).toHaveBeenCalled()
127135
expect(devtools.composeWithDevTools).toHaveBeenCalled()
128136
expect(redux.createStore).toHaveBeenCalledWith(
129137
reducer,

0 commit comments

Comments
 (0)