Skip to content

Instantly share code, notes, and snippets.

@ericat
Created July 12, 2016 09:38
Show Gist options
  • Save ericat/84151d8abdde2e1f228f39bea58b3f04 to your computer and use it in GitHub Desktop.
Save ericat/84151d8abdde2e1f228f39bea58b3f04 to your computer and use it in GitHub Desktop.
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