Files
remark42/frontend/app/store/comments/actions.test.ts
T
2021-05-06 15:55:46 -05:00

25 lines
711 B
TypeScript

import { mockStore } from '__stubs__/store';
import { LS_SORT_KEY } from 'common/constants';
import { updateSorting } from './actions';
import { COMMENTS_SET_SORT } from './types';
describe('Store comments actions', () => {
it('should save last sort to localstorage', async () => {
const newSort = '+controversy';
const store = mockStore({
comments: {
sort: '+active',
},
hiddenUsers: {},
});
await store.dispatch(updateSorting(newSort));
const [setCommentAction] = store.getActions();
expect(setCommentAction).toEqual({ type: COMMENTS_SET_SORT, payload: newSort });
expect(localStorage.setItem).toHaveBeenCalledWith(LS_SORT_KEY, newSort);
});
});