import { exampleResult } from '../../../../__mocks__/content_sources.mock' ; import React from 'react' ; import { shallow } from 'enzyme' ; import { TitleField } from './title_field' ; describe ( 'TitleField' , ( ) => { const result = { ... exampleResult . exampleDocuments [ 0 ] , foo : 'bar' , } ; it ( 'renders' , ( ) => { const props = { result , titleField : 'foo' , titleFieldHover : false , } ; const wrapper = shallow ( < TitleField { ... props } / > ) ; expect ( wrapper . find ( '[data-test-subj="TitleField"]' ) ) . toHaveLength ( 1 ) ; } ) ; it ( 'handles title when array' , ( ) => { const props = { result : { ... exampleResult . exampleDocuments [ 0 ] , foo : [ 'baz' , 'bar' ] , } , titleField : 'foo' , titleFieldHover : false , } ; const wrapper = shallow ( < TitleField { ... props } / > ) ; expect ( wrapper . find ( '[data-test-subj="CustomTitleLabel"]' ) . text ( ) ) . toEqual ( 'baz, bar' ) ; } ) ; it ( 'shows fallback URL label when no override set' , ( ) => { const props = { result , titleField : null , titleFieldHover : false , } ; const wrapper = shallow ( < TitleField { ... props } / > ) ; expect ( wrapper . find ( '[data-test-subj="DefaultTitleLabel"]' ) ) . toHaveLength ( 1 ) ; } ) ; } ) ;