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 {
410410 export import FieldValue = _firestore . FieldValue ;
411411 export import Firestore = _firestore . Firestore ;
412412 export import GeoPoint = _firestore . GeoPoint ;
413+ export import setLogFunction = _firestore . setLogFunction ;
413414}
414415
415416declare module 'firebase-admin' {
Original file line number Diff line number Diff line change @@ -126,12 +126,33 @@ function test(utils) {
126126 } ) ;
127127 }
128128
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 ( )
130150 . then ( testFirestore )
131151 . then ( testFieldValue )
132152 . then ( testFieldPath )
133153 . then ( testGeoPoint )
134- . then ( testSetDocumentReference ) ;
154+ . then ( testSetDocumentReference )
155+ . then ( testSetLogFunction ) ;
135156}
136157
137158module . exports = {
Original file line number Diff line number Diff line change @@ -36,7 +36,8 @@ import {
3636 Firestore ,
3737 FieldPath ,
3838 FieldValue ,
39- GeoPoint
39+ GeoPoint ,
40+ setLogFunction ,
4041} from '@google-cloud/firestore' ;
4142
4243chai . should ( ) ;
@@ -478,5 +479,9 @@ describe('FirebaseNamespace', () => {
478479 it ( 'should return a reference to GeoPoint type' , ( ) => {
479480 expect ( firebaseNamespace . firestore . GeoPoint ) . to . be . deep . equal ( GeoPoint ) ;
480481 } ) ;
482+
483+ it ( 'should return a reference to setLogFunction' , ( ) => {
484+ expect ( firebaseNamespace . firestore . setLogFunction ) . to . be . deep . equal ( setLogFunction ) ;
485+ } ) ;
481486 } ) ;
482487} ) ;
You can’t perform that action at this time.
0 commit comments