mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-12-11 02:09:53 -06:00
Fixed tests
This commit is contained in:
parent
9804a2d18d
commit
b011b4e1d8
@ -38,7 +38,7 @@ describe('<NotFound />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('shows a link with provided props', () => {
|
it('shows a link with provided props', () => {
|
||||||
const { wrapper } = createWrapper({ to: '/foo/bar', btnText: 'Hello' });
|
const { wrapper } = createWrapper({ to: '/foo/bar', children: 'Hello' });
|
||||||
const link = wrapper.find(Link);
|
const link = wrapper.find(Link);
|
||||||
|
|
||||||
expect(link.prop('to')).toEqual('/foo/bar');
|
expect(link.prop('to')).toEqual('/foo/bar');
|
||||||
|
|||||||
@ -58,9 +58,10 @@ describe('selectedServerReducer', () => {
|
|||||||
|
|
||||||
await selectServer(ServersServiceMock, buildApiClient)(serverId)(dispatch);
|
await selectServer(ServersServiceMock, buildApiClient)(serverId)(dispatch);
|
||||||
|
|
||||||
expect(dispatch).toHaveBeenCalledTimes(2);
|
expect(dispatch).toHaveBeenCalledTimes(3);
|
||||||
expect(dispatch).toHaveBeenNthCalledWith(1, { type: RESET_SHORT_URL_PARAMS });
|
expect(dispatch).toHaveBeenNthCalledWith(1, { type: RESET_SELECTED_SERVER });
|
||||||
expect(dispatch).toHaveBeenNthCalledWith(2, { type: SELECT_SERVER, selectedServer: expectedSelectedServer });
|
expect(dispatch).toHaveBeenNthCalledWith(2, { type: RESET_SHORT_URL_PARAMS });
|
||||||
|
expect(dispatch).toHaveBeenNthCalledWith(3, { type: SELECT_SERVER, selectedServer: expectedSelectedServer });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('invokes dependencies', async () => {
|
it('invokes dependencies', async () => {
|
||||||
@ -70,17 +71,27 @@ describe('selectedServerReducer', () => {
|
|||||||
expect(buildApiClient).toHaveBeenCalledTimes(1);
|
expect(buildApiClient).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('falls back to min version when health endpoint fails', async () => {
|
it('dispatches error when health endpoint fails', async () => {
|
||||||
const expectedSelectedServer = {
|
const expectedSelectedServer = { serverNotReachable: true };
|
||||||
...selectedServer,
|
|
||||||
version: MIN_FALLBACK_VERSION,
|
|
||||||
};
|
|
||||||
|
|
||||||
apiClientMock.health.mockRejectedValue({});
|
apiClientMock.health.mockRejectedValue({});
|
||||||
|
|
||||||
await selectServer(ServersServiceMock, buildApiClient)(serverId)(dispatch);
|
await selectServer(ServersServiceMock, buildApiClient)(serverId)(dispatch);
|
||||||
|
|
||||||
expect(dispatch).toHaveBeenNthCalledWith(2, { type: SELECT_SERVER, selectedServer: expectedSelectedServer });
|
expect(apiClientMock.health).toHaveBeenCalled();
|
||||||
|
expect(dispatch).toHaveBeenNthCalledWith(3, { type: SELECT_SERVER, selectedServer: expectedSelectedServer });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('dispatches error when server is not found', async () => {
|
||||||
|
const expectedSelectedServer = { serverNotFound: true };
|
||||||
|
|
||||||
|
ServersServiceMock.findServerById.mockReturnValue(undefined);
|
||||||
|
|
||||||
|
await selectServer(ServersServiceMock, buildApiClient)(serverId)(dispatch);
|
||||||
|
|
||||||
|
expect(ServersServiceMock.findServerById).toHaveBeenCalled();
|
||||||
|
expect(apiClientMock.health).not.toHaveBeenCalled();
|
||||||
|
expect(dispatch).toHaveBeenNthCalledWith(3, { type: SELECT_SERVER, selectedServer: expectedSelectedServer });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user