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

29 lines
1 KiB
JavaScript
Raw Normal View History

2018-08-26 11:52:45 +03:00
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', () => {
2018-09-07 21:41:21 +03:00
describe('reducer', () => {
const defaultState = { page: '1' };
2018-08-25 00:38:37 +03:00
it('returns default value when action is unknown', () =>
2018-08-26 11:52:45 +03:00
expect(reducer(defaultState, { type: 'unknown' })).toEqual(defaultState));
it('returns params when action is LIST_SHORT_URLS', () =>
2018-08-26 11:52:45 +03:00
expect(reducer(defaultState, { type: LIST_SHORT_URLS, params: { searchTerm: 'foo' } })).toEqual({
...defaultState,
searchTerm: 'foo',
}));
it('returns default value when action is RESET_SHORT_URL_PARAMS', () =>
2018-08-26 11:52:45 +03:00
expect(reducer(defaultState, { type: RESET_SHORT_URL_PARAMS })).toEqual(defaultState));
});
describe('resetShortUrlParams', () => {
it('returns proper action', () =>
expect(resetShortUrlParams()).toEqual({ type: RESET_SHORT_URL_PARAMS }));
});
});