UNPKG

@kiwicom/smart-faq

Version:

50 lines (44 loc) 1.44 kB
// @flow import * as React from 'react'; import { mount } from 'enzyme'; import chatConfig from '../__fixtures__/ChatConfig'; import { GuaranteeChatWrapperRaw } from '../GuaranteeChatWrapper'; 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()} log={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} log={jest.fn()} > {({ onClickDisplayChat }) => ( <button type="button" id="button" onClick={onClickDisplayChat} /> )} </GuaranteeChatWrapperRaw>, ); wrapper.find('#button').simulate('click'); expect(wrapper.find('#button')).toHaveLength(0); expect(toggleIsChatActive).toHaveBeenCalledWith(true); }); });