Skip to content

Commit

Permalink
Merge pull request #1515 from arnaudbenard/update-redux-mock-store-docs
Browse files Browse the repository at this point in the history
update redux-mock-store documentation
  • Loading branch information
timdorr committed Mar 11, 2016
2 parents 80d11be + 74b1188 commit 175f32a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion docs/recipes/WritingTests.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ import thunk from 'redux-thunk'
import * as actions from '../../actions/counter'
import * as types from '../../constants/ActionTypes'
import nock from 'nock'
import expect from 'expect'; // You can use any testing library

const middlewares = [ thunk ]
const mockStore = configureMockStore(middlewares)
Expand All @@ -130,8 +131,16 @@ describe('async actions', () => {
{ type: types.FETCH_TODOS_REQUEST },
{ type: types.FETCH_TODOS_SUCCESS, body: { todos: ['do something'] } }
]
const store = mockStore({ todos: [] }, expectedActions, done)
const store = mockStore({ todos: [] })

store.dispatch(actions.fetchTodos())
.then(() => {
const actions = store.getActions()

expect(actions[0].type).toEqual(types.FETCH_TODOS_REQUEST)

done()
})
})
})
```
Expand Down

0 comments on commit 175f32a

Please sign in to comment.