File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,15 @@ MockFirestore.prototype.toString = function () {
5757 return this . path ;
5858} ;
5959
60+ MockFirestore . prototype . getAll = function ( /* ...docs */ ) {
61+ var docs = Array . from ( arguments ) ;
62+ return Promise . all (
63+ docs . map ( function ( doc ) {
64+ return doc . get ( ) ;
65+ } )
66+ ) ;
67+ } ;
68+
6069MockFirestore . prototype . runTransaction = function ( transFunc ) {
6170 var batch = this . batch ( ) ;
6271 batch . get = function ( doc ) {
Original file line number Diff line number Diff line change @@ -186,4 +186,25 @@ describe('MockFirestore', function () {
186186 db . flush ( ) ;
187187 } ) ;
188188 } ) ;
189+
190+ describe ( 'getAll' , function ( ) {
191+ it ( '' , function ( ) {
192+ var doc1 = db . doc ( 'doc1' ) ;
193+ var doc2 = db . doc ( 'doc2' ) ;
194+ var doc3 = db . doc ( 'doc3' ) ;
195+
196+ db . autoFlush ( ) ;
197+
198+ doc1 . set ( { value : 1 } ) ;
199+ doc2 . set ( { value : 2 } ) ;
200+
201+ return db
202+ . getAll ( doc1 , doc2 , doc3 )
203+ . then ( function ( snaps ) {
204+ expect ( snaps [ 0 ] . data ( ) ) . to . deep . equal ( { value : 1 } ) ;
205+ expect ( snaps [ 1 ] . data ( ) ) . to . deep . equal ( { value : 2 } ) ;
206+ expect ( snaps [ 2 ] . exists ) . to . equal ( false ) ;
207+ } ) ;
208+ } ) ;
209+ } ) ;
189210} ) ;
You can’t perform that action at this time.
0 commit comments