mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-30 10:58:23 -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(() => {
|
beforeEach(() => {
|
||||||
const mockFormat = {
|
const mockFormat = {
|
||||||
format: jest.fn()
|
format: jest.fn()
|
||||||
|
@ -23,7 +23,7 @@ describe('Compose Comment test', () => {
|
||||||
.mockImplementation(() => mockFormat);
|
.mockImplementation(() => mockFormat);
|
||||||
mockFormat.format.mockReturnValue('');
|
mockFormat.format.mockReturnValue('');
|
||||||
|
|
||||||
store = mockStore({
|
defaultStore = mockStore({
|
||||||
session: {
|
session: {
|
||||||
session: {
|
session: {
|
||||||
user: {},
|
user: {},
|
||||||
|
@ -35,7 +35,10 @@ describe('Compose Comment test', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const getComposeCommentWrapper = props => {
|
const getComposeCommentWrapper = (props, store) => {
|
||||||
|
if (!store) {
|
||||||
|
store = defaultStore;
|
||||||
|
}
|
||||||
const wrapper = shallowWithIntl(
|
const wrapper = shallowWithIntl(
|
||||||
<ComposeComment
|
<ComposeComment
|
||||||
{...defaultProps()}
|
{...defaultProps()}
|
||||||
|
@ -44,7 +47,7 @@ describe('Compose Comment test', () => {
|
||||||
/>
|
/>
|
||||||
, {context: {store}}
|
, {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 ', () => {
|
test('Modal & Comment status do not show ', () => {
|
||||||
|
@ -89,6 +92,34 @@ describe('Compose Comment test', () => {
|
||||||
expect(component.find('CommentingStatus').exists()).toEqual(true);
|
expect(component.find('CommentingStatus').exists()).toEqual(true);
|
||||||
global.Date.now = realDateNow;
|
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', () => {
|
test('Comment Status shows when user just submitted a comment that got them muted', () => {
|
||||||
const realDateNow = Date.now.bind(global.Date);
|
const realDateNow = Date.now.bind(global.Date);
|
||||||
global.Date.now = () => 0;
|
global.Date.now = () => 0;
|
||||||
|
|
Loading…
Reference in a new issue