@@ -639,5 +639,32 @@ describe('Trust Involved controller', () => {
639639
640640 expect ( mockRes . redirect ) . toBeCalledWith ( `${ TRUST_ENTRY_URL + ADD_TRUST_URL } ` ) ;
641641 } ) ;
642+
643+ test ( `keeps all valid individuals and ignore dummy associated parties` , async ( ) => {
644+
645+ const individualTrustee1 = { forename : "TestOne" } as IndividualTrustee ;
646+ const individualTrustee2 = { forename : "TestTwo" } as IndividualTrustee ;
647+ const individualTrustee3 = { forename : "testThree" , surname : "TestSurname" } as IndividualTrustee ;
648+ const individualTrustee4 = { surname : "OE001022A1" } as IndividualTrustee ;
649+
650+ const mockAppData : ApplicationData = {
651+ [ TrustKey ] : [ {
652+ 'INDIVIDUALS' : [ individualTrustee1 , individualTrustee2 , individualTrustee3 , individualTrustee4 ] as TrustIndividual [ ] ,
653+ } ]
654+ } as ApplicationData ;
655+
656+ ( fetchApplicationData as jest . Mock ) . mockResolvedValue ( mockAppData ) ;
657+ mockReq . body = {
658+ noMoreToAdd : 'noMoreToAdd' ,
659+ } ;
660+ mockIsActiveFeature . mockReturnValue ( false ) ;
661+ await post ( mockReq , mockRes , mockNext ) ;
662+ await postTrustInvolvedPage ( mockReq , mockRes , mockNext , true , true ) ;
663+
664+ expect ( mockAppData . trusts ?. [ 0 ] . INDIVIDUALS ) . toEqual ( [ individualTrustee1 , individualTrustee2 , individualTrustee3 ] ) ;
665+ expect ( mockAppData . trusts ?. [ 0 ] . INDIVIDUALS ) . not . toEqual ( [ individualTrustee4 ] ) ;
666+
667+ expect ( mockRes . redirect ) . toBeCalledWith ( `${ TRUST_ENTRY_URL + ADD_TRUST_URL } ` ) ;
668+ } ) ;
642669 } ) ;
643670} ) ;
0 commit comments