import type { Type } from '@kbn/securitysolution-io-ts-list-types' ; import { getSearchEsListItemMock } from '../../schemas/elastic_response/search_es_list_item_schema.mock' ; import { SearchEsListItemSchema } from '../../schemas/elastic_response' ; import { findSourceType } from './find_source_type' ; describe ( 'find_source_type' , ( ) => { beforeEach ( ( ) => { jest . clearAllMocks ( ) ; } ) ; afterEach ( ( ) => { jest . clearAllMocks ( ) ; } ) ; test ( 'it returns the item ip if it exists' , ( ) => { const listItem = getSearchEsListItemMock ( ) ; const derivedType = findSourceType ( listItem ) ; const expected = 'ip' ; expect ( derivedType ) . toEqual ( expected ) ; } ) ; test ( 'it returns the item keyword if it exists' , ( ) => { const listItem = { ... getSearchEsListItemMock ( ) , ip : undefined , keyword : 'some keyword' , } ; const derivedType = findSourceType ( listItem ) ; const expected = 'keyword' ; expect ( derivedType ) . toEqual ( expected ) ; } ) ; test ( 'it returns a null if all the attached types are undefined' , ( ) => { const item = { ... getSearchEsListItemMock ( ) , ip : undefined , keyword : undefined , } ; expect ( findSourceType ( item ) ) . toEqual ( null ) ; } ) ; } ) ;