UNPKG

@kiwicom/smart-faq

Version:

Smart FAQ

50 lines (43 loc) 1.41 kB
// @flow import * as React from 'react'; import { mount } from 'enzyme'; import { chatConfig } from '../__mocks__/chatStuff'; import { GuaranteeChatWrapperRaw } from '../GuaranteeChatWrapper'; jest.mock('../../helpers/analytics/cuckoo'); describe('GuaranteeChatWrapper', () => { it('should show button by default', () => { const wrapper = mount( <GuaranteeChatWrapperRaw eventSource="smartFAQ" elementId="testId" guaranteeChatBookingInfo={null} chatConfig={chatConfig} isChatActive={false} toggleIsChatActive={jest.fn()} > {() => <div id="button" />} </GuaranteeChatWrapperRaw>, ); expect(wrapper.find('#button')).toHaveLength(1); }); it('should start chat when clicking on button', () => { const toggleIsChatActive = jest.fn(); const wrapper = mount( <GuaranteeChatWrapperRaw eventSource="smartFAQ" elementId="testId" guaranteeChatBookingInfo={null} chatConfig={chatConfig} isChatActive={false} toggleIsChatActive={toggleIsChatActive} > {({ onClickDisplayChat }) => ( <button id="button" onClick={onClickDisplayChat} /> )} </GuaranteeChatWrapperRaw>, ); wrapper.find('#button').simulate('click'); expect(wrapper.find('#button')).toHaveLength(0); expect(toggleIsChatActive).toBeCalled(); }); });