describe('SideBarBottom Component', () => { it('should match snapshot', () => { const tree = create(<SidebarBottom />).toJSON() expect(tree).toMatchSnapshot() }) it('should toggle options when clicked', () => { const wrapper = shallow(<SidebarBottom />) wrapper.find('.toggle-sb-options').simulate('click') expect(wrapper.state().showOptions).toBe(true) expect(wrapper.find('SidebarOptions').exists()).toBe(true) }) })
describe('GroupTopOptions Component', () => { MockDataElement() it('should match snapshot', () => { const tree = create(<GroupTopOptions />).toJSON() expect(tree).toMatchSnapshot() }) it('should show options when icon is clicked', () => { const wraper = shallow(<GroupTopOptions />) wraper.find('.pro_more_horiz').simulate('click') expect(wraper.find('.pro_banner_options').exists()).toBe(true) }) })
describe('IsAdmin Component', () => { let dataElement = MockDataElement() dataElement.setAttribute('data-isadmin', 'true') it('should match snapshot', () => { const tree = create( <Provider store={mockStore}> <IsAdmin /> </Provider> ).toJSON() expect(tree).toMatchSnapshot() }) it('should redirect to /admin-login route when user is not an admin', () => { dataElement.setAttribute('data-isadmin', 'false') const wrapper = shallow(<IsAdmin />) expect(wrapper.find('Redirect').exists()).toBe(true) }) })
describe('Recommend Component', () => { const comp = <Recommend username="ghalib" /> it('should match snapshot', () => { const tree = create(comp).toJSON() expect(tree).toMatchSnapshot() }) it('should toggle RecommendUsers modal when clicked on the button', () => { const wrapper = shallow(comp) wrapper.find('SecondaryButton').simulate('click', { preventDefault() {} }) expect(wrapper.state().recommend).toBe(true) expect(wrapper.find('Connect(RecommendUsers)').exists()).toBe(true) }) })
describe('ConversationTop Component', () => { const mockFn = jest.fn() it('should match snapshot', () => { const tree = create( <Provider store={mockStore}> <ConversationTop hideConversation={mockFn} /> </Provider> ).toJSON() expect(tree).toMatchSnapshot() }) it('should match snapshot and show <ConversationOptions/> when clicked on the expand icon', () => { const wrapper = shallow(<ConversationTop hideConversation={mockFn} />) wrapper.find('.m_m_exp').simulate('click') expect(wrapper.find('ConversationOptions').exists()).toBe(true) }) })
describe('CreateGroupModal Component', () => { it('should match snapshot', () => { const tree = create(<CreateGroupModal back={jest.fn()} />).toJSON() expect(tree).toMatchSnapshot() }) it('should redirect to /group/34 when group created', () => { const wrapper = shallow(<CreateGroupModal back={jest.fn()} />) wrapper.setState({ created: true, groupId: 34, }) expect(wrapper.find('Redirect').exists()).toBe(true) }) })
describe('BannerTopOptions Component', () => { it('should match snapshot', () => { const tree = create(<BannerTopOptions />).toJSON() expect(tree).toMatchSnapshot() }) it('should show options when icon is clicked', () => { const wraper = shallow(<BannerTopOptions />) wraper.find('.pro_more_horiz').simulate('click') expect(wraper.find('.pro_banner_options').exists()).toBe(true) }) })
describe('ChangeGroupAdmin Component', () => { MockDataElement() it('should match snapshot', () => { const tree = create( <Provider store={mockStore}> <ChangeGroupAdmin /> </Provider> ).toJSON() expect(tree).toMatchSnapshot() }) it('should show <ChangeAdmin/> when change option is clicked', () => { const wrapper = shallow(<PureChangeGroupAdmin gd={Group.group_details} />) wrapper.find('li > a').simulate('click', { preventDefault() {}, }) expect(wrapper.find('Connect(ChangeAdmin)').exists()).toBe(true) }) })
describe('CommentTypeImage Component', () => { const comp = ( <CommentTypeImage commentSrc="instagram_comment_1518972851259.jpg" /> ) it('should match snapshot', () => { const tree = create(comp).toJSON() expect(tree).toMatchSnapshot() }) it('should show <ImageTheatre/> when clicked on image', () => { const wrapper = shallow(comp) wrapper.find('.comments_img').simulate('click') expect(wrapper.find('ImageTheatre').exists()).toBe(true) }) })
describe('OnlineUsersButton Component', () => { it('should match snapshot', () => { const tree = create(<OnlineUsersButton />).toJSON() expect(tree).toMatchSnapshot() }) it('should show <OnlineUsers/> when clicked on PrimaryButton', () => { const wrapper = shallow(<OnlineUsersButton />) wrapper.find('PrimaryButton').simulate('click', { preventDefault() {}, }) expect(wrapper.state('showOnlineUsers')).toBe(true) expect(wrapper.find('Connect(OnlineUsers)').exists()).toBe(true) }) })
describe('ConversationAddEmojis Component', () => { const props = { updateMssgValue: jest.fn(), } it('should match snapshot', () => { const tree = create(<ConversationAddEmojis {...props} />).toJSON() expect(tree).toMatchSnapshot() }) it('should match snapshot and show <Emojis/> when clicked on emojis icon', () => { const wrapper = shallow(<ConversationAddEmojis {...props} />) wrapper.find('.mssg_emoji_btn').simulate('click') expect(wrapper.find('Emojis').exists()).toBe(true) }) })
describe('BannerTags Component', () => { MockDataElement() it('should match snapshot', () => { const tree = create( <Provider store={mockStore}> <BannerTags /> </Provider> ).toJSON() expect(tree).toMatchSnapshot() }) it('should show tags when toggle icon is clicked', () => { const wrapper = shallow(<BannerTags />) wrapper.find('.pro_exp_more').simulate('click') expect(wrapper.find('.pro_tags').exists()).toBe(true) }) })
describe('CreateGroup Component', () => { it('should match snapshot', () => { const tree = create(<CreateGroup />).toJSON() expect(tree).toMatchSnapshot() }) it('should show <CreateGroupModal/> when button is clicked', () => { const wrapper = shallow(<CreateGroup />) wrapper.find('SecondaryButton').simulate('click', { preventDefault() {}, }) expect(wrapper.find('CreateGroupModal').exists()).toBe(true) }) })
describe('ShowLikes Component', () => { const props = { post_id: 11, likes_count: 1, decrementLikes: jest.fn(), } it('should match snapshot', () => { const tree = create(<ShowLikes {...props} />).toJSON() expect(tree).toMatchSnapshot() }) it('should show <Likes/> when showLikes == true', () => { const wrapper = shallow(<ShowLikes {...props} />) wrapper.find('.p_likes').simulate('click') expect(wrapper.find('Connect(Likes)').exists()).toBe(true) }) })
describe('ShowSharers Component', () => { const props = { post_id: 11, shares_count: 1, decrementSharers: jest.fn(), } it('should match snapshot', () => { const tree = create(<ShowSharers {...props} />).toJSON() expect(tree).toMatchSnapshot() }) it('should show <Sharers/> when showSharers == true', () => { const wrapper = shallow(<ShowSharers {...props} />) wrapper.find('.p_comm').simulate('click') expect(wrapper.find('Connect(Sharers)').exists()).toBe(true) }) })