diff --git a/test/servers/reducers/selectedServer.test.js b/test/servers/reducers/selectedServer.test.js index 442172da..2b99d5d7 100644 --- a/test/servers/reducers/selectedServer.test.js +++ b/test/servers/reducers/selectedServer.test.js @@ -29,9 +29,6 @@ describe('selectedServerReducer', () => { }); describe('selectServer', () => { - const ShlinkApiClientMock = { - setConfig: sinon.spy(), - }; const serverId = 'abc123'; const selectedServer = { id: serverId, @@ -41,7 +38,6 @@ describe('selectedServerReducer', () => { }; afterEach(() => { - ShlinkApiClientMock.setConfig.resetHistory(); ServersServiceMock.findServerById.resetHistory(); }); @@ -49,7 +45,7 @@ describe('selectedServerReducer', () => { const dispatch = sinon.spy(); const expectedDispatchCalls = 2; - _selectServer(ShlinkApiClientMock, ServersServiceMock)(serverId)(dispatch); + _selectServer(ServersServiceMock)(serverId)(dispatch); expect(dispatch.callCount).toEqual(expectedDispatchCalls); expect(dispatch.firstCall.calledWith({ type: RESET_SHORT_URL_PARAMS })).toEqual(true); @@ -60,9 +56,8 @@ describe('selectedServerReducer', () => { }); it('invokes dependencies', () => { - _selectServer(ShlinkApiClientMock, ServersServiceMock)(serverId)(() => {}); + _selectServer(ServersServiceMock)(serverId)(() => {}); - expect(ShlinkApiClientMock.setConfig.callCount).toEqual(1); expect(ServersServiceMock.findServerById.callCount).toEqual(1); }); }); diff --git a/test/short-urls/reducers/shortUrlCreation.test.js b/test/short-urls/reducers/shortUrlCreation.test.js index ebf1dc04..28aac024 100644 --- a/test/short-urls/reducers/shortUrlCreation.test.js +++ b/test/short-urls/reducers/shortUrlCreation.test.js @@ -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); } diff --git a/test/tags/reducers/tagDelete.test.js b/test/tags/reducers/tagDelete.test.js index ece3c92d..26450c9e 100644 --- a/test/tags/reducers/tagDelete.test.js +++ b/test/tags/reducers/tagDelete.test.js @@ -48,6 +48,7 @@ describe('tagDeleteReducer', () => { deleteTags: sinon.fake.returns(result), }); const dispatch = sinon.spy(); + const getState = () => ({}); afterEach(() => dispatch.resetHistory()); @@ -55,9 +56,9 @@ describe('tagDeleteReducer', () => { const expectedDispatchCalls = 2; const tag = 'foo'; const apiClientMock = createApiClientMock(Promise.resolve()); - const dispatchable = _deleteTag(apiClientMock, tag); + const dispatchable = _deleteTag(() => apiClientMock, tag); - await dispatchable(dispatch); + await dispatchable(dispatch, getState); expect(apiClientMock.deleteTags.callCount).toEqual(1); expect(apiClientMock.deleteTags.getCall(0).args).toEqual([[ tag ]]); @@ -72,10 +73,10 @@ describe('tagDeleteReducer', () => { const error = 'Error'; const tag = 'foo'; const apiClientMock = createApiClientMock(Promise.reject(error)); - const dispatchable = _deleteTag(apiClientMock, tag); + const dispatchable = _deleteTag(() => apiClientMock, tag); try { - await dispatchable(dispatch); + await dispatchable(dispatch, getState); } catch (e) { expect(e).toEqual(error); } diff --git a/test/tags/reducers/tagEdit.test.js b/test/tags/reducers/tagEdit.test.js index 8a1ca80c..ed97cf67 100644 --- a/test/tags/reducers/tagEdit.test.js +++ b/test/tags/reducers/tagEdit.test.js @@ -55,6 +55,7 @@ describe('tagEditReducer', () => { setColorForKey: sinon.spy(), }; const dispatch = sinon.spy(); + const getState = () => ({}); afterEach(() => { colorGenerator.setColorForKey.resetHistory(); @@ -67,9 +68,9 @@ describe('tagEditReducer', () => { const newName = 'bar'; const color = '#ff0000'; const apiClientMock = createApiClientMock(Promise.resolve()); - const dispatchable = _editTag(apiClientMock, colorGenerator, oldName, newName, color); + const dispatchable = _editTag(() => apiClientMock, colorGenerator, oldName, newName, color); - await dispatchable(dispatch); + await dispatchable(dispatch, getState); expect(apiClientMock.editTag.callCount).toEqual(1); expect(apiClientMock.editTag.getCall(0).args).toEqual([ oldName, newName ]); @@ -89,10 +90,10 @@ describe('tagEditReducer', () => { const newName = 'bar'; const color = '#ff0000'; const apiClientMock = createApiClientMock(Promise.reject(error)); - const dispatchable = _editTag(apiClientMock, colorGenerator, oldName, newName, color); + const dispatchable = _editTag(() => apiClientMock, colorGenerator, oldName, newName, color); try { - await dispatchable(dispatch); + await dispatchable(dispatch, getState); } catch (e) { expect(e).toEqual(error); } diff --git a/test/visits/reducers/shortUrlDetail.test.js b/test/visits/reducers/shortUrlDetail.test.js index 8fac8e71..2be3426f 100644 --- a/test/visits/reducers/shortUrlDetail.test.js +++ b/test/visits/reducers/shortUrlDetail.test.js @@ -50,6 +50,7 @@ describe('shortUrlDetailReducer', () => { getShortUrl: sinon.fake.returns(returned), }); const dispatchMock = sinon.spy(); + const getState = () => ({}); beforeEach(() => dispatchMock.resetHistory()); @@ -57,7 +58,7 @@ describe('shortUrlDetailReducer', () => { const ShlinkApiClient = buildApiClientMock(Promise.reject()); const expectedDispatchCalls = 2; - await _getShortUrlDetail(ShlinkApiClient, 'abc123')(dispatchMock); + await _getShortUrlDetail(() => ShlinkApiClient, 'abc123')(dispatchMock, getState); const [ firstCallArg ] = dispatchMock.getCall(0).args; const { type: firstCallType } = firstCallArg; @@ -76,7 +77,7 @@ describe('shortUrlDetailReducer', () => { const ShlinkApiClient = buildApiClientMock(Promise.resolve(resolvedShortUrl)); const expectedDispatchCalls = 2; - await _getShortUrlDetail(ShlinkApiClient, 'abc123')(dispatchMock); + await _getShortUrlDetail(() => ShlinkApiClient, 'abc123')(dispatchMock, getState); const [ firstCallArg ] = dispatchMock.getCall(0).args; const { type: firstCallType } = firstCallArg; diff --git a/test/visits/reducers/shortUrlVisits.test.js b/test/visits/reducers/shortUrlVisits.test.js index 04888841..f3e47ff1 100644 --- a/test/visits/reducers/shortUrlVisits.test.js +++ b/test/visits/reducers/shortUrlVisits.test.js @@ -50,6 +50,7 @@ describe('shortUrlVisitsReducer', () => { getShortUrlVisits: sinon.fake.returns(returned), }); const dispatchMock = sinon.spy(); + const getState = () => ({}); beforeEach(() => dispatchMock.resetHistory()); @@ -57,7 +58,7 @@ describe('shortUrlVisitsReducer', () => { const ShlinkApiClient = buildApiClientMock(Promise.reject()); const expectedDispatchCalls = 2; - await _getShortUrlVisits(ShlinkApiClient, 'abc123')(dispatchMock); + await _getShortUrlVisits(() => ShlinkApiClient, 'abc123')(dispatchMock, getState); const [ firstCallArg ] = dispatchMock.getCall(0).args; const { type: firstCallType } = firstCallArg; @@ -76,7 +77,7 @@ describe('shortUrlVisitsReducer', () => { const ShlinkApiClient = buildApiClientMock(Promise.resolve(resolvedVisits)); const expectedDispatchCalls = 2; - await _getShortUrlVisits(ShlinkApiClient, 'abc123')(dispatchMock); + await _getShortUrlVisits(() => ShlinkApiClient, 'abc123')(dispatchMock, getState); const [ firstCallArg ] = dispatchMock.getCall(0).args; const { type: firstCallType } = firstCallArg;