Skip to content
This repository has been archived by the owner on Jun 21, 2019. It is now read-only.

Commit

Permalink
Add unit test for failed get request
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémi Koenig committed Sep 23, 2016
1 parent e53ba10 commit c17c661
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/EndPoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);

var mock = new MockAdapter(EndPoint.axios, {delayResponse: 50});
mock.onAny('/api/error/').reply(500);
mock.onAny(/.*/).reply(200);

chai.use(chaiSubset);
Expand All @@ -36,6 +37,18 @@ describe('EndPoint', () => {
}).catch(done);
});

it('creates _request and _error actions for a failed endPoint.get()', (done) => {
const store = mockStore({});
const endPoint = new EndPoint('test', {url: '/api/error/'});
store.dispatch(endPoint.get()).catch(() => {
expect(store.getActions().map(action => action.type)).to.eql([
'@@super-api@test_request',
'@@super-api@test_error'
]);
done();
});
});

it('aborts request on reset', () => {
const store = mockStore({});
const endPoint = new EndPoint('test', {url: '/api/buckets/'});
Expand Down

0 comments on commit c17c661

Please sign in to comment.