Files
remark42/frontend/app/store/comments/actions.test.ts
T
2020-03-25 01:52:46 -05:00

32 lines
891 B
TypeScript

import { mockStore } from '@app/testUtils/mockStore';
import { LS_SORT_KEY } from '@app/common/constants';
import { updateSorting } from './actions';
import { COMMENTS_SET_SORT } from './types';
describe('Store comments actions', () => {
beforeAll(() => {
require('jest-fetch-mock').enableMocks();
});
afterAll(() => {
require('jest-fetch-mock').resetMocks();
});
it('handles changing a purchase status and fetches all purchases', 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);
});
});