diff --git a/frontend/app/components/comment-form/comment-form.test.tsx b/frontend/app/components/comment-form/comment-form.test.tsx index 77f3a1ad..31ad5489 100644 --- a/frontend/app/components/comment-form/comment-form.test.tsx +++ b/frontend/app/components/comment-form/comment-form.test.tsx @@ -2,7 +2,7 @@ import { createElement } from 'preact'; import { shallow } from 'enzyme'; -import { user } from '@app/testUtils/mocks/user'; +import { user, anonymousUser } from '@app/testUtils/mocks/user'; import { StaticStore } from '@app/common/static_store'; import { LS_SAVED_COMMENT_VALUE } from '@app/common/constants'; import * as localStorageModule from '@app/common/local-storage'; @@ -131,4 +131,24 @@ describe('', () => { expect(localStorage.getItem(LS_SAVED_COMMENT_VALUE)).toBe(JSON.stringify({})); }); }); + + it('should show error message of image upload try by anonymous user', () => { + const props = { ...DEFAULT_PROPS, anonymousUser, intl }; + const wrapper = shallow(); + // @ts-ignore + const instance: CommentForm = wrapper.instance(); + + instance.onDrop(new Event('drag') as DragEvent); + expect(wrapper.exists('.comment-form__error')).toEqual(true); + }); + + it('should show error message of image upload try by unauthorized user', () => { + const props = { ...DEFAULT_PROPS, intl }; + const wrapper = shallow(); + // @ts-ignore + const instance: CommentForm = wrapper.instance(); + + instance.onDrop(new Event('drag') as DragEvent); + expect(wrapper.exists('.comment-form__error')).toEqual(true); + }); });