mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-17 04:53:49 +00:00
Fixed test throwing unhandled promise
This commit is contained in:
@@ -36,6 +36,12 @@ describe('selectedServerReducer', () => {
|
|||||||
const apiClientMock = {
|
const apiClientMock = {
|
||||||
health: jest.fn().mockResolvedValue({ version }),
|
health: jest.fn().mockResolvedValue({ version }),
|
||||||
};
|
};
|
||||||
|
const buildApiClient = jest.fn().mockResolvedValue(apiClientMock);
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
apiClientMock.health.mockClear();
|
||||||
|
buildApiClient.mockClear();
|
||||||
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
ServersServiceMock.findServerById.mockClear();
|
ServersServiceMock.findServerById.mockClear();
|
||||||
@@ -48,17 +54,18 @@ describe('selectedServerReducer', () => {
|
|||||||
version,
|
version,
|
||||||
};
|
};
|
||||||
|
|
||||||
await selectServer(ServersServiceMock, async () => apiClientMock)(serverId)(dispatch);
|
await selectServer(ServersServiceMock, buildApiClient)(serverId)(dispatch);
|
||||||
|
|
||||||
expect(dispatch).toHaveBeenCalledTimes(2);
|
expect(dispatch).toHaveBeenCalledTimes(2);
|
||||||
expect(dispatch).toHaveBeenNthCalledWith(1, { type: RESET_SHORT_URL_PARAMS });
|
expect(dispatch).toHaveBeenNthCalledWith(1, { type: RESET_SHORT_URL_PARAMS });
|
||||||
expect(dispatch).toHaveBeenNthCalledWith(2, { type: SELECT_SERVER, selectedServer: expectedSelectedServer });
|
expect(dispatch).toHaveBeenNthCalledWith(2, { type: SELECT_SERVER, selectedServer: expectedSelectedServer });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('invokes dependencies', () => {
|
it('invokes dependencies', async () => {
|
||||||
selectServer(ServersServiceMock)(serverId)(() => {});
|
await selectServer(ServersServiceMock, buildApiClient)(serverId)(() => {});
|
||||||
|
|
||||||
expect(ServersServiceMock.findServerById).toHaveBeenCalledTimes(1);
|
expect(ServersServiceMock.findServerById).toHaveBeenCalledTimes(1);
|
||||||
|
expect(buildApiClient).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user