@@ -663,11 +663,37 @@ describe('updateCaseAndAssociations', () => {
663
663
userId : practitionerId ,
664
664
} ) ;
665
665
} ) ;
666
+
667
+ it ( 'calls updateIrsPractitionerOnCase to update gsi1pk for unchanged irsPractitioners when the case is part of a consolidated group' , async ( ) => {
668
+ await updateCaseAndAssociations ( {
669
+ applicationContext,
670
+ caseToUpdate : {
671
+ ...mockCaseWithIrsPractitioners ,
672
+ leadDocketNumber : '101-23' ,
673
+ } ,
674
+ } ) ;
675
+
676
+ expect (
677
+ applicationContext . getPersistenceGateway ( )
678
+ . removePrivatePractitionerOnCase ,
679
+ ) . not . toHaveBeenCalled ( ) ;
680
+ expect (
681
+ applicationContext . getPersistenceGateway ( ) . updateIrsPractitionerOnCase ,
682
+ ) . toHaveBeenCalled ( ) ;
683
+ expect (
684
+ applicationContext . getPersistenceGateway ( ) . updateIrsPractitionerOnCase
685
+ . mock . calls [ 0 ] [ 0 ] ,
686
+ ) . toMatchObject ( {
687
+ docketNumber : validMockCase . docketNumber ,
688
+ practitioner : mockCaseWithIrsPractitioners . irsPractitioners ! [ 0 ] ,
689
+ userId : practitionerId ,
690
+ } ) ;
691
+ } ) ;
666
692
} ) ;
667
693
668
694
describe ( 'Private practitioners' , ( ) => {
669
695
const practitionerId = applicationContext . getUniqueId ( ) ;
670
- const mockCaseWithIrsPractitioners = new Case (
696
+ const mockCaseWithIrsAndPrivatePractitioners = new Case (
671
697
{
672
698
...MOCK_CASE ,
673
699
privatePractitioners : [
@@ -685,13 +711,15 @@ describe('updateCaseAndAssociations', () => {
685
711
beforeAll ( ( ) => {
686
712
applicationContext
687
713
. getPersistenceGateway ( )
688
- . getCaseByDocketNumber . mockReturnValue ( mockCaseWithIrsPractitioners ) ;
714
+ . getCaseByDocketNumber . mockReturnValue (
715
+ mockCaseWithIrsAndPrivatePractitioners ,
716
+ ) ;
689
717
} ) ;
690
718
691
719
it ( 'does not call updatePrivatePractitionerOnCase or removePrivatePractitionerOnCase if all private practitioners are unchanged' , async ( ) => {
692
720
await updateCaseAndAssociations ( {
693
721
applicationContext,
694
- caseToUpdate : mockCaseWithIrsPractitioners ,
722
+ caseToUpdate : mockCaseWithIrsAndPrivatePractitioners ,
695
723
} ) ;
696
724
expect (
697
725
applicationContext . getPersistenceGateway ( )
@@ -713,7 +741,7 @@ describe('updateCaseAndAssociations', () => {
713
741
await updateCaseAndAssociations ( {
714
742
applicationContext,
715
743
caseToUpdate : {
716
- ...mockCaseWithIrsPractitioners ,
744
+ ...mockCaseWithIrsAndPrivatePractitioners ,
717
745
privatePractitioners : [ updatedPractitioner ] ,
718
746
} ,
719
747
} ) ;
@@ -736,11 +764,39 @@ describe('updateCaseAndAssociations', () => {
736
764
} ) ;
737
765
} ) ;
738
766
767
+ it ( 'calls updatePrivatePractitionerOnCase to update gsi1pk for unchanged privatePractitioners when the case is part of a consolidated group' , async ( ) => {
768
+ await updateCaseAndAssociations ( {
769
+ applicationContext,
770
+ caseToUpdate : {
771
+ ...mockCaseWithIrsAndPrivatePractitioners ,
772
+ leadDocketNumber : '101-23' ,
773
+ } ,
774
+ } ) ;
775
+
776
+ expect (
777
+ applicationContext . getPersistenceGateway ( )
778
+ . removePrivatePractitionerOnCase ,
779
+ ) . not . toHaveBeenCalled ( ) ;
780
+ expect (
781
+ applicationContext . getPersistenceGateway ( )
782
+ . updatePrivatePractitionerOnCase ,
783
+ ) . toHaveBeenCalled ( ) ;
784
+ expect (
785
+ applicationContext . getPersistenceGateway ( )
786
+ . updatePrivatePractitionerOnCase . mock . calls [ 0 ] [ 0 ] ,
787
+ ) . toMatchObject ( {
788
+ docketNumber : validMockCase . docketNumber ,
789
+ practitioner :
790
+ mockCaseWithIrsAndPrivatePractitioners . privatePractitioners ! [ 0 ] ,
791
+ userId : practitionerId ,
792
+ } ) ;
793
+ } ) ;
794
+
739
795
it ( 'removes an privatePractitioner from a case with existing privatePractitioners' , async ( ) => {
740
796
await updateCaseAndAssociations ( {
741
797
applicationContext,
742
798
caseToUpdate : {
743
- ...mockCaseWithIrsPractitioners ,
799
+ ...mockCaseWithIrsAndPrivatePractitioners ,
744
800
privatePractitioners : [ ] ,
745
801
} ,
746
802
} ) ;
0 commit comments