Fixed tests

This commit is contained in:
Alejandro Celaya
2018-12-18 10:23:09 +01:00
parent 4f54e3315f
commit 79a0a5e4ea
6 changed files with 23 additions and 23 deletions

View File

@@ -54,6 +54,7 @@ describe('shortUrlCreationReducer', () => {
createShortUrl: sinon.fake.returns(result),
});
const dispatch = sinon.spy();
const getState = () => ({});
afterEach(() => dispatch.resetHistory());
@@ -61,9 +62,9 @@ describe('shortUrlCreationReducer', () => {
const expectedDispatchCalls = 2;
const result = 'foo';
const apiClientMock = createApiClientMock(Promise.resolve(result));
const dispatchable = _createShortUrl(apiClientMock, {});
const dispatchable = _createShortUrl(() => apiClientMock, {});
await dispatchable(dispatch);
await dispatchable(dispatch, getState);
expect(apiClientMock.createShortUrl.callCount).toEqual(1);
@@ -76,10 +77,10 @@ describe('shortUrlCreationReducer', () => {
const expectedDispatchCalls = 2;
const error = 'Error';
const apiClientMock = createApiClientMock(Promise.reject(error));
const dispatchable = _createShortUrl(apiClientMock, {});
const dispatchable = _createShortUrl(() => apiClientMock, {});
try {
await dispatchable(dispatch);
await dispatchable(dispatch, getState);
} catch (e) {
expect(e).toEqual(error);
}