mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 09:35:56 -05:00
Test that status gets correctly set in constructor
This commit is contained in:
parent
1744108570
commit
d8a802fca2
1 changed files with 31 additions and 2 deletions
|
@ -51,6 +51,36 @@ describe('Compose Comment test', () => {
|
||||||
return wrapper.dive(); // unwrap redux connect(injectIntl(ComposeComment))
|
return wrapper.dive(); // unwrap redux connect(injectIntl(ComposeComment))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
test('status is EDITING when props do not contain a muteStatus ', () => {
|
||||||
|
const commentInstance = getComposeCommentWrapper({}).instance();
|
||||||
|
expect(commentInstance.state.status).toBe('EDITING');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('status is COMPOSE_DISALLOWED when props contain a future mute', () => {
|
||||||
|
jest.useFakeTimers();
|
||||||
|
const realDateNow = Date.now.bind(global.Date);
|
||||||
|
global.Date.now = () => 0;
|
||||||
|
const mutedStore = mockStore({
|
||||||
|
session: {
|
||||||
|
session: {
|
||||||
|
user: {},
|
||||||
|
permissions: {
|
||||||
|
mute_status: {
|
||||||
|
muteExpiresAt: 5,
|
||||||
|
offenses: [],
|
||||||
|
showWarning: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const component = getComposeCommentWrapper({}, mutedStore);
|
||||||
|
const commentInstance = component.instance();
|
||||||
|
|
||||||
|
expect(commentInstance.state.status).toBe('COMPOSE_DISALLOWED');
|
||||||
|
global.Date.now = realDateNow;
|
||||||
|
});
|
||||||
|
|
||||||
test('Modal & Comment status do not show ', () => {
|
test('Modal & Comment status do not show ', () => {
|
||||||
const component = getComposeCommentWrapper({});
|
const component = getComposeCommentWrapper({});
|
||||||
// Comment compsoe box is there
|
// Comment compsoe box is there
|
||||||
|
@ -360,7 +390,6 @@ describe('Compose Comment test', () => {
|
||||||
expect(component.find('MuteModal').exists()).toEqual(true);
|
expect(component.find('MuteModal').exists()).toEqual(true);
|
||||||
expect(component.find('MuteModal').props().showFeedback).toBe(false);
|
expect(component.find('MuteModal').props().showFeedback).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('shouldShowMuteModal is false when muteStatus is undefined ', () => {
|
test('shouldShowMuteModal is false when muteStatus is undefined ', () => {
|
||||||
const commentInstance = getComposeCommentWrapper({}).instance();
|
const commentInstance = getComposeCommentWrapper({}).instance();
|
||||||
expect(commentInstance.shouldShowMuteModal()).toBe(false);
|
expect(commentInstance.shouldShowMuteModal()).toBe(false);
|
||||||
|
|
Loading…
Reference in a new issue