From 1744108570ca036ef505b8c49e005d81c5ee2f2a Mon Sep 17 00:00:00 2001 From: seotts Date: Fri, 19 Mar 2021 15:29:29 -0400 Subject: [PATCH] Add test of shoudShowMuteModal when isReply --- test/unit/components/compose-comment.test.jsx | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/unit/components/compose-comment.test.jsx b/test/unit/components/compose-comment.test.jsx index a454799f5..6caf12314 100644 --- a/test/unit/components/compose-comment.test.jsx +++ b/test/unit/components/compose-comment.test.jsx @@ -458,7 +458,25 @@ describe('Compose Comment test', () => { global.Date.now = realDateNow; }); - test('getMuteModalStartStep: not a reply ', () => { + test('shouldShowMuteModal is true when the user is already muted if the comment is a reply', () => { + const realDateNow = Date.now.bind(global.Date); + global.Date.now = () => 0; + // Since Date.now mocked to 0 above, we just need a small number to make + // it look like it was created < 2 minutes ago. + const offense = { + expiresAt: '1000', + createdAt: '-60' // ~1 ago min given shouldShowMuteModal's conversions, + }; + const muteStatus = { + offenses: [offense] + }; + const justMuted = false; + const commentInstance = getComposeCommentWrapper({isReply: true}).instance(); + expect(commentInstance.shouldShowMuteModal(muteStatus, justMuted)).toBe(true); + global.Date.now = realDateNow; + }); + + test('getMuteModalStartStep: not a reply', () => { const commentInstance = getComposeCommentWrapper({}).instance(); expect(commentInstance.getMuteModalStartStep()).toBe(0); });