import { setBirthRegistrationSectionTransformer , changeHirerchyMutationTransformer } from '@client/forms/register/fieldMappings/birth/mutation/registration-mappings' ; import { mockApplicationData , mockBirthRegistrationSectionData } from '@client/tests/util' ; import { TransformedData , IFormField } from '@client/forms' ; import { cloneDeep } from 'lodash' ; describe ( 'Birth registration mutation mapping related tests' , ( ) => { it ( 'Test certificate mapping with other collector data' , ( ) => { const transformedData = { registration : { } } ; const mockBirthApplication = cloneDeep ( mockApplicationData ) ; mockBirthApplication . registration = mockBirthRegistrationSectionData ; setBirthRegistrationSectionTransformer ( transformedData , mockBirthApplication , 'registration' ) ; expect ( transformedData . registration ) . toBeDefined ( ) ; expect ( transformedData . registration . trackingId ) . toEqual ( 'BDSS0SE' ) ; expect ( transformedData . registration . certificates ) . toEqual ( [ { collector : { relationship : 'OTHER' , otherRelationship : 'Uncle' , individual : { name : [ { use : 'en' , firstNames : 'Mushraful' , familyName : 'Hoque' } ] , identifier : [ { id : '123456789' , type : 'PASSPORT' } ] } , affidavit : [ { contentType : 'abc' , data : 'BASE64 data' } ] } , hasShowedVerifiedDocument : true } ] ) ; } ) ; it ( 'Test certificate mapping without any data' , ( ) => { const transformedData = { registration : { } } ; setBirthRegistrationSectionTransformer ( transformedData , mockApplicationData , 'registration' ) ; expect ( transformedData . registration ) . toBeDefined ( ) ; expect ( transformedData . registration . registrationNumber ) . toEqual ( '201908122365BDSS0SE1' ) ; expect ( transformedData . registration . certificates ) . toEqual ( [ { } ] ) ; } ) ; it ( 'changeHierarchyMutation transformer test' , ( ) => { const transformedData = { registrationPhone : '' } ; const mockBirthApplication = cloneDeep ( mockApplicationData ) ; mockBirthApplication . registration = mockBirthRegistrationSectionData ; const field = { name : 'whoseContactDetails' } as IFormField ; changeHirerchyMutationTransformer ( ) ( transformedData , mockBirthApplication , 'registration' , field , { name : 'registrationPhone' } as IFormField ) ; expect ( transformedData ) . toEqual ( { registrationPhone : '01557394986' } ) ; } ) ; } ) ;