import '../../../../__mocks__/shallow_useeffect.mock' ; import { setMockValues , setMockActions } from '../../../../__mocks__/kea_logic' ; import React from 'react' ; import { shallow } from 'enzyme' ; import { EuiFieldText } from '@elastic/eui' ; import { ContentSection } from '../../../components/shared/content_section' ; import { BrandingSection } from './branding_section' ; import { Customize } from './customize' ; describe ( 'Customize' , ( ) => { const onOrgNameInputChange = jest . fn ( ) ; const updateOrgName = jest . fn ( ) ; beforeEach ( ( ) => { setMockActions ( { onOrgNameInputChange , updateOrgName } ) ; setMockValues ( { orgNameInputValue : '' } ) ; } ) ; it ( 'renders' , ( ) => { const wrapper = shallow ( < Customize />); expect ( wrapper . find ( ContentSection ) ) . toHaveLength ( 1 ) ; expect ( wrapper . find ( BrandingSection ) ) . toHaveLength ( 2 ) ; } ) ; it ( 'handles input change' , ( ) => { const wrapper = shallow ( < Customize />); const input = wrapper . find ( EuiFieldText ) ; input . simulate ( 'change' , { target : { value : 'foobar' } } ) ; expect ( onOrgNameInputChange ) . toHaveBeenCalledWith ( 'foobar' ) ; } ) ; it ( 'handles form submission' , ( ) => { const wrapper = shallow ( < Customize />); const preventDefault = jest . fn ( ) ; wrapper . find ( 'form' ) . simulate ( 'submit' , { preventDefault } ) ; expect ( updateOrgName ) . toHaveBeenCalled ( ) ; } ) ; } ) ;