Files
remark42/frontend/app/store/thread/reducers.test.ts
T
2019-04-28 19:27:36 +03:00

37 lines
1.1 KiB
TypeScript

import { Comment } from '@app/common/types';
import { setCollapse } from './actions';
import { THREAD_SET_COLLAPSE } from './types';
describe('collapsedThreads', () => {
it('should set collapsed to true', () => {
const comment = { id: 'some-id' } as Comment;
const node = { comment, replies: [] };
const state = { collapsedThreads: {}, comments: [node] };
const dispatch = jest.fn();
const getState = jest.fn(() => state) as any;
setCollapse(comment.id, true)(dispatch, getState, undefined);
expect(dispatch).toBeCalledWith({
type: THREAD_SET_COLLAPSE,
id: 'some-id',
collapsed: true,
});
});
it('should collapse toggled', () => {
const comment = { id: 'some-id' } as Comment;
const node = { comment, replies: [] };
const dispatch = jest.fn();
const getState = jest.fn();
getState.mockReturnValue({ collapsedThreads: { 'some-id': true }, comments: [node] });
setCollapse(comment.id, false)(dispatch, getState, undefined);
expect(dispatch).toBeCalledWith({
type: THREAD_SET_COLLAPSE,
id: 'some-id',
collapsed: false,
});
});
});