import { removeNestedFieldChildren } from './new_job_capabilities_service_analytics' ; import type { DataView } from '../../../../../../../src/plugins/data_views/public' ; import nestedFieldIndexResponse from '../__mocks__/nested_field_index_response.json' ; const indexPattern = { id : 'nested-field-index' , title : 'nested-field-index' , } as unknown as DataView ; describe ( 'removeNestedFieldChildren' , ( ) => { describe ( 'cloudwatch newJobCapsAnalytics()' , ( ) => { it ( 'can get job caps fields from endpoint json' , async ( ) => { const fields = removeNestedFieldChildren ( nestedFieldIndexResponse , indexPattern . title ) ; const nestedField = fields . find ( ( { type } ) => type === 'nested' ) ; const nestedFieldRoot = nestedField ?. name ; const regex = new RegExp ( `^${ nestedFieldRoot }\\.` , 'i' ) ; expect ( fields ) . toHaveLength ( 4 ) ; expect ( fields . some ( ( field ) => field . name . match ( regex ) ) ) . toBe ( false ) ; } ) ; } ) ; } ) ;