shlink-web-client/test/short-urls/reducers/shortUrlsListParams.test.ts

27 lines
973 B
TypeScript
Raw Normal View History

2018-08-26 11:52:45 +03:00
import reducer, {
RESET_SHORT_URL_PARAMS,
resetShortUrlParams,
2020-08-26 19:55:40 +03:00
ShortUrlsListParams,
} from '../../../src/short-urls/reducers/shortUrlsListParams';
import { LIST_SHORT_URLS } from '../../../src/short-urls/reducers/shortUrlsList';
describe('shortUrlsListParamsReducer', () => {
2018-09-07 21:41:21 +03:00
describe('reducer', () => {
2020-08-26 19:55:40 +03:00
const defaultState: ShortUrlsListParams = { page: '1' };
it('returns params when action is LIST_SHORT_URLS', () =>
2020-08-26 19:55:40 +03:00
expect(reducer(undefined, { type: LIST_SHORT_URLS, params: { searchTerm: 'foo', page: '2' } })).toEqual({
page: '2',
searchTerm: 'foo',
}));
it('returns default value when action is RESET_SHORT_URL_PARAMS', () =>
2020-08-26 19:55:40 +03:00
expect(reducer(undefined, { type: RESET_SHORT_URL_PARAMS, params: defaultState })).toEqual(defaultState));
});
describe('resetShortUrlParams', () => {
it('returns proper action', () =>
expect(resetShortUrlParams()).toEqual({ type: RESET_SHORT_URL_PARAMS }));
});
});