UNPKG

@kiwicom/smart-faq

Version:

Smart FAQ

48 lines (41 loc) 1.35 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} onToggleIsClosable={jest.fn()} > {() => <div id="button" />} </GuaranteeChatWrapperRaw>, ); expect(wrapper.find('#button')).toHaveLength(1); }); it('should start chat when clicking on button', () => { const onToggleIsClosable = jest.fn(); const wrapper = mount( <GuaranteeChatWrapperRaw eventSource="smartFAQ" elementId="testId" guaranteeChatBookingInfo={null} chatConfig={chatConfig} onToggleIsClosable={onToggleIsClosable} > {({ onClickDisplayChat }) => ( <button id="button" onClick={onClickDisplayChat} /> )} </GuaranteeChatWrapperRaw>, ); wrapper.find('#button').simulate('click'); expect(wrapper.find('#button')).toHaveLength(0); expect(onToggleIsClosable).toBeCalled(); }); });