Add tests

This commit is contained in:
Serge Adamovich
2020-04-19 20:41:46 +03:00
parent 2f966d09ca
commit 7115329060
@@ -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('<CommentForm />', () => {
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(<CommentForm {...props} />);
// @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(<CommentForm {...props} />);
// @ts-ignore
const instance: CommentForm = wrapper.instance();
instance.onDrop(new Event('drag') as DragEvent);
expect(wrapper.exists('.comment-form__error')).toEqual(true);
});
});