Created
July 12, 2016 09:38
-
-
Save ericat/84151d8abdde2e1f228f39bea58b3f04 to your computer and use it in GitHub Desktop.
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
import configureMockStore from 'redux-mock-store'; | |
import thunk from 'redux-thunk'; | |
import nock from 'nock'; | |
import expect from 'expect'; | |
import sinon from 'sinon'; | |
import * as actions from './actions'; | |
import * as types from './constants'; | |
const middlewares = [thunk]; | |
const mockStore = configureMockStore(middlewares); | |
describe('Feeds actions', () => { | |
var link; | |
beforeEach(function() { | |
link = { | |
title: 'A pretty title', | |
author: 'Erica Salvaneschi', | |
}; | |
}); | |
afterEach(() => { | |
nock.cleanAll(); | |
}); | |
it('creates LOAD_FEED', () => { | |
nock('http://localhost:8080') | |
.get('/v1/feed/123') | |
.reply(200, {body: {links: [link]}}); | |
const expectedActions = [{ | |
type: types.LOAD_FEED, | |
body: {links: [link]}, | |
}]; | |
const store = mockStore({links: []}); | |
const dispatch = sinon.spy(store, 'dispatch'); | |
store.dispatch(actions.loadFeed('123')); | |
expect(dispatch.calledWith({type: 'LOAD_FEED', links: [link]})); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment