1515 */
1616
1717import {
18- stubAdminApi ,
19- newEventContext ,
20- newDocumentSnapshot ,
21- newCountQuery ,
2218 createMockFirestore ,
19+ newCountQuery ,
20+ newDocumentSnapshot ,
21+ newEventContext ,
22+ stubAdminApi ,
2323} from '@ground/lib/testing/firestore' ;
2424import * as functions from './index' ;
2525import { loi } from './common/datastore' ;
26- import { Firestore } from 'firebase-admin/firestore' ;
26+ import { DocumentSnapshot , Firestore } from 'firebase-admin/firestore' ;
27+ import firebaseFunctionsTest from 'firebase-functions-test' ;
2728import { resetDatastore } from './common/context' ;
2829import { registry } from '@ground/lib' ;
2930import { GroundProtos } from '@ground/proto' ;
3031
31- const test = require ( 'firebase-functions-test' ) ( ) ;
32+ const test = firebaseFunctionsTest ( ) ;
3233
3334import Pb = GroundProtos . ground . v1beta1 ;
3435const l = registry . getFieldIds ( Pb . LocationOfInterest ) ;
@@ -77,7 +78,7 @@ describe('onWriteSubmission()', () => {
7778 installSubmissionCountSpy ( SUBMISSIONS_PATH , LOI_ID , 2 ) ;
7879
7980 await test . wrap ( functions . onWriteSubmission ) (
80- { before : undefined , after : SUBMISSION } ,
81+ { before : null as unknown as DocumentSnapshot , after : SUBMISSION } ,
8182 CONTEXT
8283 ) ;
8384
@@ -89,7 +90,7 @@ describe('onWriteSubmission()', () => {
8990 installSubmissionCountSpy ( SUBMISSIONS_PATH , LOI_ID , 1 ) ;
9091
9192 await test . wrap ( functions . onWriteSubmission ) (
92- { before : SUBMISSION , after : undefined } ,
93+ { before : SUBMISSION , after : null as unknown as DocumentSnapshot } ,
9394 CONTEXT
9495 ) ;
9596
@@ -101,7 +102,10 @@ describe('onWriteSubmission()', () => {
101102 installSubmissionCountSpy ( SUBMISSIONS_PATH , LOI_ID , 1 ) ;
102103
103104 await test . wrap ( functions . onWriteSubmission ) (
104- { before : undefined , after : undefined } ,
105+ {
106+ before : null as unknown as DocumentSnapshot ,
107+ after : null as unknown as DocumentSnapshot ,
108+ } ,
105109 CONTEXT
106110 ) ;
107111
@@ -119,7 +123,7 @@ describe('onWriteSubmission()', () => {
119123
120124 await expectAsync (
121125 test . wrap ( functions . onWriteSubmission ) (
122- { before : undefined , after : SUBMISSION } ,
126+ { before : null as unknown as DocumentSnapshot , after : SUBMISSION } ,
123127 CONTEXT
124128 )
125129 ) . toBeRejected ( ) ;
0 commit comments