File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-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 @@ -248,4 +248,26 @@ describe('MockFirestore', function () {
248248 } ) ;
249249 } ) ;
250250 } ) ;
251+
252+ describe ( '#getAll' , function ( ) {
253+ it ( 'gets the value of all passed documents' , function ( ) {
254+ var doc1 = db . doc ( 'doc1' ) ;
255+ var doc2 = db . doc ( 'doc2' ) ;
256+ var doc3 = db . doc ( 'doc3' ) ;
257+
258+ doc1 . set ( { value : 1 } ) ;
259+ doc2 . set ( { value : 2 } ) ;
260+
261+ var getAll = db
262+ . getAll ( doc1 , doc2 , doc3 ) ;
263+
264+ db . flush ( ) ;
265+
266+ return getAll . then ( function ( snaps ) {
267+ expect ( snaps [ 0 ] . data ( ) ) . to . deep . equal ( { value : 1 } ) ;
268+ expect ( snaps [ 1 ] . data ( ) ) . to . deep . equal ( { value : 2 } ) ;
269+ expect ( snaps [ 2 ] . exists ) . to . equal ( false ) ;
270+ } ) ;
271+ } ) ;
272+ } ) ;
251273} ) ;
You can’t perform that action at this time.
0 commit comments