@@ -558,6 +558,23 @@ describe("firestore", () => {
558
558
expect ( func . run ( true as any ) ) . to . eq ( 2 ) ;
559
559
expect ( func . __endpoint ) . to . deep . eq ( expectedEp ) ;
560
560
} ) ;
561
+
562
+ it ( "calls init function" , async ( ) => {
563
+ const event : firestore . RawFirestoreEvent = {
564
+ ...eventBase ,
565
+ datacontenttype : "application/json" ,
566
+ data : {
567
+ oldValue : null ,
568
+ value : null ,
569
+ } ,
570
+ } ;
571
+
572
+ let hello ;
573
+ onInit ( ( ) => ( hello = "world" ) ) ;
574
+ expect ( hello ) . to . be . undefined ;
575
+ await firestore . onDocumentWrittenWithAuthContext ( "path" , ( ) => null ) ( event ) ;
576
+ expect ( hello ) . to . equal ( "world" ) ;
577
+ } ) ;
561
578
} ) ;
562
579
563
580
describe ( "onDocumentCreatedWithAuthContext" , ( ) => {
@@ -605,6 +622,23 @@ describe("firestore", () => {
605
622
expect ( func . run ( true as any ) ) . to . eq ( 2 ) ;
606
623
expect ( func . __endpoint ) . to . deep . eq ( expectedEp ) ;
607
624
} ) ;
625
+
626
+ it ( "calls init function" , async ( ) => {
627
+ const event : firestore . RawFirestoreEvent = {
628
+ ...eventBase ,
629
+ datacontenttype : "application/json" ,
630
+ data : {
631
+ oldValue : null ,
632
+ value : null ,
633
+ } ,
634
+ } ;
635
+
636
+ let hello ;
637
+ onInit ( ( ) => ( hello = "world" ) ) ;
638
+ expect ( hello ) . to . be . undefined ;
639
+ await firestore . onDocumentCreatedWithAuthContext ( "path" , ( ) => null ) ( event ) ;
640
+ expect ( hello ) . to . equal ( "world" ) ;
641
+ } ) ;
608
642
} ) ;
609
643
610
644
describe ( "onDocumentUpdatedWithAuthContext" , ( ) => {
@@ -652,6 +686,23 @@ describe("firestore", () => {
652
686
expect ( func . run ( true as any ) ) . to . eq ( 2 ) ;
653
687
expect ( func . __endpoint ) . to . deep . eq ( expectedEp ) ;
654
688
} ) ;
689
+
690
+ it ( "calls init function" , async ( ) => {
691
+ const event : firestore . RawFirestoreEvent = {
692
+ ...eventBase ,
693
+ datacontenttype : "application/json" ,
694
+ data : {
695
+ oldValue : null ,
696
+ value : null ,
697
+ } ,
698
+ } ;
699
+
700
+ let hello ;
701
+ onInit ( ( ) => ( hello = "world" ) ) ;
702
+ expect ( hello ) . to . be . undefined ;
703
+ await firestore . onDocumentUpdatedWithAuthContext ( "path" , ( ) => null ) ( event ) ;
704
+ expect ( hello ) . to . equal ( "world" ) ;
705
+ } ) ;
655
706
} ) ;
656
707
657
708
describe ( "onDocumentDeletedWithAuthContext" , ( ) => {
@@ -699,6 +750,23 @@ describe("firestore", () => {
699
750
expect ( func . run ( true as any ) ) . to . eq ( 2 ) ;
700
751
expect ( func . __endpoint ) . to . deep . eq ( expectedEp ) ;
701
752
} ) ;
753
+
754
+ it ( "calls init function" , async ( ) => {
755
+ const event : firestore . RawFirestoreEvent = {
756
+ ...eventBase ,
757
+ datacontenttype : "application/json" ,
758
+ data : {
759
+ oldValue : null ,
760
+ value : null ,
761
+ } ,
762
+ } ;
763
+
764
+ let hello ;
765
+ onInit ( ( ) => ( hello = "world" ) ) ;
766
+ expect ( hello ) . to . be . undefined ;
767
+ await firestore . onDocumentDeletedWithAuthContext ( "path" , ( ) => null ) ( event ) ;
768
+ expect ( hello ) . to . equal ( "world" ) ;
769
+ } ) ;
702
770
} ) ;
703
771
704
772
describe ( "getOpts" , ( ) => {
0 commit comments