Commit 92667c09 authored by picklesrus's avatar picklesrus

Add tests and expose steps enum so it can be referenced from outside MuteModal

parent f7bf2049
......@@ -240,8 +240,8 @@ MuteModal.propTypes = {
}),
onRequestClose: PropTypes.func,
showWarning: PropTypes.bool,
startStep: PropTypes.number,
startStep: PropTypes.oneOf(Object.keys(steps)),
timeMuted: PropTypes.string
};
MuteModal.steps = steps;
module.exports = injectIntl(MuteModal);
......@@ -344,7 +344,7 @@ class ComposeComment extends React.Component {
muteModalMessages={this.getMuteMessageInfo()}
shouldCloseOnOverlayClick={false}
showWarning={this.state.showWarning}
startStep={this.props.isReply ? 1 : 0}
startStep={this.props.isReply ? MuteModal.steps.MUTE_INFO : MuteModal.steps.COMMENT_ISSUE}
timeMuted={formatTime.formatRelativeTime(this.state.muteExpiresAtMs, window._locale)}
onRequestClose={this.handleMuteClose}
/>
......
......@@ -101,6 +101,46 @@ describe('Compose Comment test', () => {
global.Date.now = realDateNow;
});
test('Comment Status and compose box do not show on replies when muted, but mute modal does', () => {
const realDateNow = Date.now.bind(global.Date);
global.Date.now = () => 0;
const store = mockStore({
session: {
session: {
user: {},
permissions: {
mute_status: {
muteExpiresAt: 5,
offenses: [],
showWarning: true
}
}
}
}
});
const component = mountWithIntl(
<ComposeComment
{...defaultProps()}
isReply
/>
, {context: {store}}
);
expect(component.find('FlexRow.compose-comment').exists()).toEqual(false);
expect(component.find('MuteModal').exists()).toBe(true);
expect(component.find('MuteModal').props().startStep).toBe(1);
expect(component.find('CommentingStatus').exists()).toEqual(false);
global.Date.now = realDateNow;
});
test('Comment Status and compose box show on replies when not muted', () => {
const realDateNow = Date.now.bind(global.Date);
global.Date.now = () => 0;
const component = getComposeCommentWrapper({isReply:true});
expect(component.find('FlexRow.compose-comment').exists()).toEqual(true);
expect(component.find('CommentingStatus').exists()).toEqual(false);
global.Date.now = realDateNow;
});
test('Comment Status initialized properly when muted', () => {
jest.useFakeTimers();
const realDateNow = Date.now.bind(global.Date);
......@@ -207,6 +247,7 @@ describe('Compose Comment test', () => {
commentInstance.setState({muteOpen: true});
component.update();
expect(component.find('MuteModal').exists()).toEqual(true);
expect(component.find('MuteModal').props().startStep).toEqual(0);
expect(component.find('MuteModal').props().showWarning).toBe(false);
global.Date.now = realDateNow;
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment