File tree Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -410,6 +410,7 @@ declare namespace admin.firestore {
410
410
export import FieldValue = _firestore . FieldValue ;
411
411
export import Firestore = _firestore . Firestore ;
412
412
export import GeoPoint = _firestore . GeoPoint ;
413
+ export import setLogFunction = _firestore . setLogFunction ;
413
414
}
414
415
415
416
declare module 'firebase-admin' {
Original file line number Diff line number Diff line change @@ -126,12 +126,33 @@ function test(utils) {
126
126
} ) ;
127
127
}
128
128
129
- return Promise . resolve ( )
129
+ function testSetLogFunction ( ) {
130
+ const logs = [ ] ;
131
+ const source = admin . firestore ( ) . collection ( 'cities' ) . doc ( ) ;
132
+ return Promise . resolve ( ) . then ( ( ) => {
133
+ admin . firestore . setLogFunction ( ( log ) => {
134
+ logs . push ( log ) ;
135
+ } )
136
+ return source . set ( { name : 'San Francisco' } ) ;
137
+ } ) . then ( result => {
138
+ return source . delete ( ) ;
139
+ } ) . then ( result => {
140
+ utils . assert (
141
+ logs . length > 0 ,
142
+ 'firestore.setLogFunction()' ,
143
+ 'Log function did not update' ) ;
144
+ } ) . catch ( err => {
145
+ utils . logFailure ( 'firestore.setLogFunction()' , 'Error while setting log function: ' + err ) ;
146
+ } ) ;
147
+ }
148
+
149
+ return Promise . resolve ( )
130
150
. then ( testFirestore )
131
151
. then ( testFieldValue )
132
152
. then ( testFieldPath )
133
153
. then ( testGeoPoint )
134
- . then ( testSetDocumentReference ) ;
154
+ . then ( testSetDocumentReference )
155
+ . then ( testSetLogFunction ) ;
135
156
}
136
157
137
158
module . exports = {
Original file line number Diff line number Diff line change @@ -36,7 +36,8 @@ import {
36
36
Firestore ,
37
37
FieldPath ,
38
38
FieldValue ,
39
- GeoPoint
39
+ GeoPoint ,
40
+ setLogFunction ,
40
41
} from '@google-cloud/firestore' ;
41
42
42
43
chai . should ( ) ;
@@ -478,5 +479,9 @@ describe('FirebaseNamespace', () => {
478
479
it ( 'should return a reference to GeoPoint type' , ( ) => {
479
480
expect ( firebaseNamespace . firestore . GeoPoint ) . to . be . deep . equal ( GeoPoint ) ;
480
481
} ) ;
482
+
483
+ it ( 'should return a reference to setLogFunction' , ( ) => {
484
+ expect ( firebaseNamespace . firestore . setLogFunction ) . to . be . deep . equal ( setLogFunction ) ;
485
+ } ) ;
481
486
} ) ;
482
487
} ) ;
You can’t perform that action at this time.
0 commit comments