mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 09:35:56 -05:00
Add a test that the constructor properly sets muteExpriresAtMs by converting from seconds to ms.
This commit is contained in:
parent
110077e8e8
commit
242fedbfe6
1 changed files with 35 additions and 4 deletions
|
@ -13,7 +13,7 @@ describe('Compose Comment test', () => {
|
|||
}
|
||||
});
|
||||
|
||||
let store;
|
||||
let defaultStore;
|
||||
beforeEach(() => {
|
||||
const mockFormat = {
|
||||
format: jest.fn()
|
||||
|
@ -23,7 +23,7 @@ describe('Compose Comment test', () => {
|
|||
.mockImplementation(() => mockFormat);
|
||||
mockFormat.format.mockReturnValue('');
|
||||
|
||||
store = mockStore({
|
||||
defaultStore = mockStore({
|
||||
session: {
|
||||
session: {
|
||||
user: {},
|
||||
|
@ -35,7 +35,10 @@ describe('Compose Comment test', () => {
|
|||
});
|
||||
});
|
||||
|
||||
const getComposeCommentWrapper = props => {
|
||||
const getComposeCommentWrapper = (props, store) => {
|
||||
if (!store) {
|
||||
store = defaultStore;
|
||||
}
|
||||
const wrapper = shallowWithIntl(
|
||||
<ComposeComment
|
||||
{...defaultProps()}
|
||||
|
@ -44,7 +47,7 @@ describe('Compose Comment test', () => {
|
|||
/>
|
||||
, {context: {store}}
|
||||
);
|
||||
return wrapper.dive(); // unwrap redux connect(injectIntl(JoinFlow))
|
||||
return wrapper.dive(); // unwrap redux connect(injectIntl(ComposeComment))
|
||||
};
|
||||
|
||||
test('Modal & Comment status do not show ', () => {
|
||||
|
@ -89,6 +92,34 @@ describe('Compose Comment test', () => {
|
|||
expect(component.find('CommentingStatus').exists()).toEqual(true);
|
||||
global.Date.now = realDateNow;
|
||||
});
|
||||
|
||||
test('Comment Status initialized properly when muted', () => {
|
||||
const realDateNow = Date.now.bind(global.Date);
|
||||
global.Date.now = () => 0;
|
||||
const mutedStore = mockStore({
|
||||
session: {
|
||||
session: {
|
||||
user: {},
|
||||
permissions: {
|
||||
mute_status: {
|
||||
muteExpiresAt: 5,
|
||||
offenses: []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
const component = getComposeCommentWrapper({}, mutedStore);
|
||||
const commentInstance = component.instance();
|
||||
// Check conversion to ms from seconds is done at init time.
|
||||
expect(commentInstance.state.muteExpiresAtMs).toEqual(5 * 1000);
|
||||
// Compose box should be hidden if muted unless they got muted due to a comment they just posted.
|
||||
expect(component.find('FlexRow.compose-comment').exists()).toEqual(false);
|
||||
expect(component.find('MuteModal').exists()).toEqual(false);
|
||||
expect(component.find('CommentingStatus').exists()).toEqual(true);
|
||||
global.Date.now = realDateNow;
|
||||
});
|
||||
|
||||
test('Comment Status shows when user just submitted a comment that got them muted', () => {
|
||||
const realDateNow = Date.now.bind(global.Date);
|
||||
global.Date.now = () => 0;
|
||||
|
|
Loading…
Reference in a new issue