Skip to content

Instantly share code, notes, and snippets.

@marr
Created January 29, 2016 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marr/a3195dadb924a977a00a to your computer and use it in GitHub Desktop.
Save marr/a3195dadb924a977a00a to your computer and use it in GitHub Desktop.
import test from 'tape'
import configureMockStore from 'redux-mock-store'
import thunk from 'redux-thunk'
import { asyncFindUsers } from '../actions'
import { FIND_USERS } from '../constants'
import nock from 'nock'
test('should find concierge user', (assert) => {
const middlewares = [ thunk ]
const mockStore = configureMockStore(middlewares)
const email = 'test-user@something.com'
nock('https://api.something.com')
.get(`/v1/account?country=US&email=${email}`)
.reply(200, { data: { email } })
const expectedActions = [{
type: FIND_USERS,
payload: [{
email
}]
}]
const store = mockStore({ users: [] }, expectedActions, assert.end)
store.dispatch(asyncFindUsers(email))
});
test('after all', () => {
nock.cleanAll()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment