adastra-ui-comment
Version:
Testing locally 1) in this file - `npm i` install dependencies - `npm run build` or `npm run tsc` to build your module 2) in childApp - in package.json under dependencies add ui-astra-assets with file:(relativePathToRepo) - "ui-astra-a
41 lines • 1.42 kB
JavaScript
import { CommentItem, } from 'CommentSection/components/CommentItem';
describe('CommentSection', () => {
const commentProps = {
comment: {
id: '1',
message: 'hi',
createdDate: '1/1/2018',
author: 'Matt',
authorId: 'test',
isOwner: true,
},
divider: true,
key: '1',
};
let props;
beforeAll(() => {
props = Object.assign({}, commentProps);
props.deleteComment = jest.fn();
});
afterAll(() => {
});
it('hitting delete should start delete countdown', () => {
const commentItem = new CommentItem(props);
commentItem.setState = jest.fn();
commentItem['onDelete']();
expect(commentItem.setState).toBeCalledWith({ toBeDeleted: true, toBeDeletedComment: props.comment });
});
it('hitting undo delete should stop delete countdown', () => {
const commentItem = new CommentItem(props);
commentItem.setState = jest.fn();
commentItem['undoDelete']();
expect(commentItem.setState).toBeCalledWith({ toBeDeleted: false });
});
it('hitting reply should call reply prop', () => {
const commentItem = new CommentItem(props);
props.replyComment = jest.fn();
commentItem['onReply']();
expect(props.replyComment).toBeCalled();
});
});
//# sourceMappingURL=CommentItem.test.js.map