import '../../../../../__mocks__/shallow_useeffect.mock' ; import { setMockValues } from '../../../../../__mocks__/kea_logic' ; import { exampleResult } from '../../../../__mocks__/content_sources.mock' ; import React from 'react' ; import { shallow } from 'enzyme' ; import { CustomSourceIcon } from './custom_source_icon' ; import { ExampleStandoutResult } from './example_standout_result' ; describe ( 'ExampleStandoutResult' , ( ) => { beforeEach ( ( ) => { setMockValues ( { ... exampleResult } ) ; } ) ; it ( 'renders' , ( ) => { const wrapper = shallow ( < ExampleStandoutResult />); expect ( wrapper . find ( '[data-test-subj="ExampleStandoutResult"]' ) ) . toHaveLength ( 1 ) ; } ) ; it ( 'sets correct color prop when dark' , ( ) => { setMockValues ( { ... exampleResult , searchResultConfig : { color : '#000' , detailFields : [ ] } } ) ; const wrapper = shallow ( < ExampleStandoutResult />); expect ( wrapper . find ( CustomSourceIcon ) . prop ( 'color' ) ) . toEqual ( 'white' ) ; } ) ; it ( 'shows fallback URL label when no override set' , ( ) => { setMockValues ( { ... exampleResult , searchResultConfig : { detailFields : [ ] , color : '#111' } } ) ; const wrapper = shallow ( < ExampleStandoutResult />); expect ( wrapper . find ( '[data-test-subj="DefaultDescriptionLabel"]' ) ) . toHaveLength ( 1 ) ; } ) ; it ( 'renders optional fields if they exist in result' , ( ) => { setMockValues ( { ... exampleResult , exampleDocuments : [ { myLink : 'http://foo' , otherTitle : 'foo' , otherType : 'File' , otherMediaType : 'PDF' , otherCreatedBy : 'bar' , otherUpdatedBy : 'baz' , } , ] , } ) ; const wrapper = shallow ( < ExampleStandoutResult />); expect ( wrapper . find ( '[data-test-subj="CreatedByField"]' ) ) . toHaveLength ( 1 ) ; expect ( wrapper . find ( '[data-test-subj="UpdatedByField"]' ) ) . toHaveLength ( 1 ) ; expect ( wrapper . find ( '[data-test-subj="TypeField"]' ) ) . toHaveLength ( 1 ) ; expect ( wrapper . find ( '[data-test-subj="MediaTypeField"]' ) ) . toHaveLength ( 1 ) ; } ) ; } ) ;