mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-06-01 01:56:20 +00:00
Removed remaining usages of sinon
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import * as sinon from 'sinon';
|
||||
import reducer, {
|
||||
CREATE_SHORT_URL_START,
|
||||
CREATE_SHORT_URL_ERROR,
|
||||
@@ -48,12 +47,12 @@ describe('shortUrlCreationReducer', () => {
|
||||
|
||||
describe('createShortUrl', () => {
|
||||
const createApiClientMock = (result) => ({
|
||||
createShortUrl: sinon.fake.returns(result),
|
||||
createShortUrl: jest.fn(() => result),
|
||||
});
|
||||
const dispatch = sinon.spy();
|
||||
const dispatch = jest.fn();
|
||||
const getState = () => ({});
|
||||
|
||||
afterEach(() => dispatch.resetHistory());
|
||||
afterEach(() => dispatch.mockReset());
|
||||
|
||||
it('calls API on success', async () => {
|
||||
const expectedDispatchCalls = 2;
|
||||
@@ -62,12 +61,12 @@ describe('shortUrlCreationReducer', () => {
|
||||
const dispatchable = createShortUrl(() => apiClientMock)({});
|
||||
|
||||
await dispatchable(dispatch, getState);
|
||||
const [ firstDispatchCallArgs, secondDispatchCallArgs ] = dispatch.mock.calls;
|
||||
|
||||
expect(apiClientMock.createShortUrl.callCount).toEqual(1);
|
||||
|
||||
expect(dispatch.callCount).toEqual(expectedDispatchCalls);
|
||||
expect(dispatch.getCall(0).args).toEqual([{ type: CREATE_SHORT_URL_START }]);
|
||||
expect(dispatch.getCall(1).args).toEqual([{ type: CREATE_SHORT_URL, result }]);
|
||||
expect(apiClientMock.createShortUrl).toHaveBeenCalledTimes(1);
|
||||
expect(dispatch).toHaveBeenCalledTimes(expectedDispatchCalls);
|
||||
expect(firstDispatchCallArgs).toEqual([{ type: CREATE_SHORT_URL_START }]);
|
||||
expect(secondDispatchCallArgs).toEqual([{ type: CREATE_SHORT_URL, result }]);
|
||||
});
|
||||
|
||||
it('throws on error', async () => {
|
||||
@@ -81,12 +80,12 @@ describe('shortUrlCreationReducer', () => {
|
||||
} catch (e) {
|
||||
expect(e).toEqual(error);
|
||||
}
|
||||
const [ firstDispatchCallArgs, secondDispatchCallArgs ] = dispatch.mock.calls;
|
||||
|
||||
expect(apiClientMock.createShortUrl.callCount).toEqual(1);
|
||||
|
||||
expect(dispatch.callCount).toEqual(expectedDispatchCalls);
|
||||
expect(dispatch.getCall(0).args).toEqual([{ type: CREATE_SHORT_URL_START }]);
|
||||
expect(dispatch.getCall(1).args).toEqual([{ type: CREATE_SHORT_URL_ERROR }]);
|
||||
expect(apiClientMock.createShortUrl).toHaveBeenCalledTimes(1);
|
||||
expect(dispatch).toHaveBeenCalledTimes(expectedDispatchCalls);
|
||||
expect(firstDispatchCallArgs).toEqual([{ type: CREATE_SHORT_URL_START }]);
|
||||
expect(secondDispatchCallArgs).toEqual([{ type: CREATE_SHORT_URL_ERROR }]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user