import { disableUnknownTypeMappingFields } from './migration_context' ; describe ( 'disableUnknownTypeMappingFields' , ( ) => { const sourceMappings = { _meta : { migrationMappingPropertyHashes : { unknown_type : 'md5hash' , unknown_core_field : 'md5hash' , known_type : 'oldmd5hash' , } , } , properties : { unknown_type : { properties : { unused_field : { type : 'text' } , } , } , unknown_core_field : { type : 'keyword' } , known_type : { properties : { field_1 : { type : 'text' } , old_field : { type : 'boolean' } , } , } , } , } ; const activeMappings = { _meta : { migrationMappingPropertyHashes : { known_type : 'md5hash' , } , } , properties : { known_type : { properties : { new_field : { type : 'binary' } , field_1 : { type : 'keyword' } , } , } , } , } ; const targetMappings = disableUnknownTypeMappingFields ( activeMappings , sourceMappings ) ; it ( 'disables complex field mappings from unknown types in the source mappings' , ( ) => { expect ( targetMappings . properties . unknown_type ) . toEqual ( { dynamic : false , properties : { } } ) ; } ) ; it ( 'retains unknown core field mappings from the source mappings' , ( ) => { expect ( targetMappings . properties . unknown_core_field ) . toEqual ( { type : 'keyword' } ) ; } ) ; it ( 'overrides source mappings with known types from active mappings' , ( ) => { expect ( targetMappings . properties . known_type ) . toEqual ( { properties : { new_field : { type : 'binary' } , field_1 : { type : 'keyword' } , } , } ) ; } ) ; it ( 'retains the active mappings _meta ignoring any _meta fields in the source mappings' , ( ) => { expect ( targetMappings . _meta ) . toEqual ( { migrationMappingPropertyHashes : { known_type : 'md5hash' , } , } ) ; } ) ; } ) ;