mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-02-24 13:24:13 -05:00
Add tests
This commit is contained in:
parent
fcbcef244b
commit
17307cacd3
2 changed files with 42 additions and 1 deletions
|
@ -75,7 +75,7 @@ const StudioComments = ({
|
||||||
<h2><FormattedMessage id="studio.commentsHeader" /></h2>
|
<h2><FormattedMessage id="studio.commentsHeader" /></h2>
|
||||||
{canEditCommentsAllowed && <StudioCommentsAllowed />}
|
{canEditCommentsAllowed && <StudioCommentsAllowed />}
|
||||||
</div>
|
</div>
|
||||||
{studioCommentsGloballyEnabled ?
|
{!hasFetchedSession || studioCommentsGloballyEnabled ?
|
||||||
<div>
|
<div>
|
||||||
{shouldShowCommentComposer ?
|
{shouldShowCommentComposer ?
|
||||||
(commentsAllowed ?
|
(commentsAllowed ?
|
||||||
|
|
|
@ -69,4 +69,45 @@ describe('Studio comments', () => {
|
||||||
);
|
);
|
||||||
expect(resetComments).not.toHaveBeenCalled();
|
expect(resetComments).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Comments do not show when they are off globally', () => {
|
||||||
|
const component = mountWithIntl(
|
||||||
|
<StudioComments
|
||||||
|
hasFetchedSession
|
||||||
|
isAdmin={false}
|
||||||
|
comments={[{id: 123, author: {}}]}
|
||||||
|
studioCommentsGloballyEnabled={false}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
expect(component.find('div.studio-compose-container').exists()).toBe(true);
|
||||||
|
expect(component.find('CommentingStatus').exists()).toBe(true);
|
||||||
|
expect(component.find('TopLevelComment').exists()).toBe(false);
|
||||||
|
});
|
||||||
|
test('Comments do show when they are on globally', () => {
|
||||||
|
const component = mountWithIntl(
|
||||||
|
<StudioComments
|
||||||
|
hasFetchedSession
|
||||||
|
isAdmin={false}
|
||||||
|
comments={[{id: 123, author: {}}]}
|
||||||
|
studioCommentsGloballyEnabled
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
expect(component.find('div.studio-compose-container').exists()).toBe(true);
|
||||||
|
expect(component.find('CommentingStatus').exists()).toBe(false);
|
||||||
|
expect(component.find('TopLevelComment').exists()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Comments off status does not show if we have not fetched the session', () => {
|
||||||
|
const component = mountWithIntl(
|
||||||
|
<StudioComments
|
||||||
|
hasFetchedSession={false}
|
||||||
|
isAdmin={false}
|
||||||
|
comments={[{id: 123, author: {}}]}
|
||||||
|
studioCommentsGloballyEnabled={false}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
expect(component.find('div.studio-compose-container').exists()).toBe(true);
|
||||||
|
expect(component.find('CommentingStatus').exists()).toBe(false);
|
||||||
|
expect(component.find('TopLevelComment').exists()).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue