Add tests

This commit is contained in:
picklesrus 2021-06-10 16:51:41 -04:00
parent fcbcef244b
commit 17307cacd3
2 changed files with 42 additions and 1 deletions

View file

@ -75,7 +75,7 @@ const StudioComments = ({
<h2><FormattedMessage id="studio.commentsHeader" /></h2>
{canEditCommentsAllowed && <StudioCommentsAllowed />}
</div>
{studioCommentsGloballyEnabled ?
{!hasFetchedSession || studioCommentsGloballyEnabled ?
<div>
{shouldShowCommentComposer ?
(commentsAllowed ?

View file

@ -69,4 +69,45 @@ describe('Studio comments', () => {
);
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);
});
});