import { toSanitizedFieldType } from './fields_utils' ; import type { FieldSpec } from '../../../data/common' ; describe ( 'fields_utils' , ( ) => { describe ( 'toSanitizedFieldType' , ( ) => { const mockedField = { lang : 'painless' , conflictDescriptions : { } , aggregatable : true , name : 'name' , type : 'type' , esTypes : [ 'long' , 'geo' ] , } as FieldSpec ; test ( 'should sanitize fields ' , async ( ) => { const fields = [ mockedField ] as FieldSpec [ ] ; expect ( toSanitizedFieldType ( fields ) ) . toMatchInlineSnapshot ( `
        Array [
          Object {
            "label": "name",
            "name": "name",
            "type": "type",
          },
        ]
      ` ) ; } ) ; test ( 'should filter non-aggregatable fields' , async ( ) => { const fields = [ { ... mockedField , aggregatable : false , } , ] ; expect ( toSanitizedFieldType ( fields ) ) . toMatchInlineSnapshot ( `Array []` ) ; } ) ; test ( 'should filter nested fields' , async ( ) => { const fields = [ { ... mockedField , subType : { nested : { path : 'path' , } , } , } , ] ; expect ( toSanitizedFieldType ( fields ) ) . toMatchInlineSnapshot ( `Array []` ) ; } ) ; } ) ; } ) ;