mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-01 05:06:39 +00:00
Removed shortUrlsListParams reducer, as the state is now handled internally in the component
This commit is contained in:
@@ -8,7 +8,6 @@ import reducer, {
|
||||
MAX_FALLBACK_VERSION,
|
||||
MIN_FALLBACK_VERSION,
|
||||
} from '../../../src/servers/reducers/selectedServer';
|
||||
import { RESET_SHORT_URL_PARAMS } from '../../../src/short-urls/reducers/shortUrlsListParams';
|
||||
import { ShlinkState } from '../../../src/container/types';
|
||||
import { NonReachableServer, NotFoundServer, RegularServer } from '../../../src/servers/data';
|
||||
|
||||
@@ -62,10 +61,9 @@ describe('selectedServerReducer', () => {
|
||||
|
||||
await selectServer(buildApiClient, loadMercureInfo)(id)(dispatch, getState);
|
||||
|
||||
expect(dispatch).toHaveBeenCalledTimes(4);
|
||||
expect(dispatch).toHaveBeenCalledTimes(3);
|
||||
expect(dispatch).toHaveBeenNthCalledWith(1, { type: RESET_SELECTED_SERVER });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(2, { type: RESET_SHORT_URL_PARAMS });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(3, { type: SELECT_SERVER, selectedServer: expectedSelectedServer });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(2, { type: SELECT_SERVER, selectedServer: expectedSelectedServer });
|
||||
expect(loadMercureInfo).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
@@ -89,7 +87,7 @@ describe('selectedServerReducer', () => {
|
||||
await selectServer(buildApiClient, loadMercureInfo)(id)(dispatch, getState);
|
||||
|
||||
expect(apiClientMock.health).toHaveBeenCalled();
|
||||
expect(dispatch).toHaveBeenNthCalledWith(3, { type: SELECT_SERVER, selectedServer: expectedSelectedServer });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(2, { type: SELECT_SERVER, selectedServer: expectedSelectedServer });
|
||||
expect(loadMercureInfo).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -102,7 +100,7 @@ describe('selectedServerReducer', () => {
|
||||
|
||||
expect(getState).toHaveBeenCalled();
|
||||
expect(apiClientMock.health).not.toHaveBeenCalled();
|
||||
expect(dispatch).toHaveBeenNthCalledWith(3, { type: SELECT_SERVER, selectedServer: expectedSelectedServer });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(2, { type: SELECT_SERVER, selectedServer: expectedSelectedServer });
|
||||
expect(loadMercureInfo).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -33,18 +33,16 @@ describe('<ShortUrlsList />', () => {
|
||||
},
|
||||
});
|
||||
const ShortUrlsList = shortUrlsListCreator(ShortUrlsTable, SearchBar);
|
||||
const createWrapper = (orderBy: ShortUrlsOrder = {}) => shallow(
|
||||
const createWrapper = (defaultOrdering: ShortUrlsOrder = {}) => shallow(
|
||||
<ShortUrlsList
|
||||
{...Mock.of<MercureBoundProps>({ mercureInfo: { loading: true } })}
|
||||
listShortUrls={listShortUrlsMock}
|
||||
resetShortUrlParams={jest.fn()}
|
||||
shortUrlsListParams={{ page: '1', orderBy }}
|
||||
match={Mock.of<match<ShortUrlListRouteParams>>({ params: {} })}
|
||||
location={Mock.of<Location>({ search: '?tags=test%20tag&search=example.com' })}
|
||||
shortUrlsList={shortUrlsList}
|
||||
history={Mock.of<History>({ push })}
|
||||
selectedServer={Mock.of<ReachableServer>({ id: '1' })}
|
||||
settings={Mock.all<Settings>()}
|
||||
settings={Mock.of<Settings>({ shortUrlList: { defaultOrdering } })}
|
||||
/>,
|
||||
).dive(); // Dive is needed as this component is wrapped in a HOC
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
import reducer, {
|
||||
RESET_SHORT_URL_PARAMS,
|
||||
resetShortUrlParams,
|
||||
} from '../../../src/short-urls/reducers/shortUrlsListParams';
|
||||
import { LIST_SHORT_URLS } from '../../../src/short-urls/reducers/shortUrlsList';
|
||||
|
||||
describe('shortUrlsListParamsReducer', () => {
|
||||
describe('reducer', () => {
|
||||
it('returns params when action is LIST_SHORT_URLS', () =>
|
||||
expect(reducer(undefined, { type: LIST_SHORT_URLS, params: { searchTerm: 'foo', page: '2' } } as any)).toEqual({
|
||||
page: '2',
|
||||
searchTerm: 'foo',
|
||||
}));
|
||||
|
||||
it('returns default value when action is RESET_SHORT_URL_PARAMS', () =>
|
||||
expect(reducer(undefined, { type: RESET_SHORT_URL_PARAMS } as any)).toEqual({ page: '1' }));
|
||||
});
|
||||
|
||||
describe('resetShortUrlParams', () => {
|
||||
it('returns proper action', () =>
|
||||
expect(resetShortUrlParams()).toEqual({ type: RESET_SHORT_URL_PARAMS }));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user