1- /** firebase-mock - v2.2.2
1+ /** firebase-mock - v2.2.3
22https://github.com/soumak77/firebase-mock
33* Copyright (c) 2016 Brian Soumakian
44* License: MIT */
5- (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.firebasemock = f()}})(function(){var define,module,exports;return (function(){function e(t ,n,r ){function s(o,u ){if(!n[o ]){if(!t[o ]){var a=typeof require== "function"&&require;if(!u&&a )return a(o ,!0);if(i )return i(o ,!0);var f =new Error("Cannot find module '"+o +"'");throw f .code="MODULE_NOT_FOUND",f }var l =n[o ]={exports:{}};t[o ][0].call(l .exports,function(e ){var n=t[o ][1][e ];return s(n?n:e )},l,l .exports,e,t,n,r )}return n[o ].exports}var i=typeof require== "function"&&require;for(var o =0;o<r .length;o ++)s(r[o ]);return s }return e })()({1:[function(require,module,exports){
5+ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.firebasemock = f()}})(function(){var define,module,exports;return (function(){function r(e ,n,t ){function o(i,f ){if(!n[i ]){if(!e[i ]){var c= "function"==typeof require &&require;if(!f&&c )return c(i ,!0);if(u )return u(i ,!0);var a =new Error("Cannot find module '"+i +"'");throw a .code="MODULE_NOT_FOUND",a }var p =n[i ]={exports:{}};e[i ][0].call(p .exports,function(r ){var n=e[i ][1][r ];return o(n||r )},p,p .exports,r,e,n,t )}return n[i ].exports}for( var u= "function"==typeof require &&require,i =0;i<t .length;i ++)o(t[i ]);return o }return r })()({1:[function(require,module,exports){
66(function (global){
77'use strict';
88
@@ -44263,12 +44263,10 @@ MockFirebase.restoreClock = function () {
4426344263 getServerTime = defaultClock;
4426444264};
4426544265
44266- MockFirebase.defaultAutoId = function () {
44266+ MockFirebase.autoId = function () {
4426744267 return autoId(new Date().getTime());
4426844268};
4426944269
44270- MockFirebase.autoId = MockFirebase.defaultAutoId;
44271-
4427244270MockFirebase.prototype.flush = function (delay) {
4427344271 this.queue.flush(delay);
4427444272 return this;
@@ -44446,9 +44444,10 @@ MockFirebase.prototype.push = function (data, callback) {
4444644444 if (arguments.length && data !== null) {
4444744445 // currently, callback only invoked if child exists
4444844446 validate.data(data);
44449- child.set(data, callback);
44447+ return utils.createThenableReference(child, child.set(data, callback));
44448+ } else {
44449+ return utils.createThenableReference(child, Promise.resolve(null));
4445044450 }
44451- return child;
4445244451};
4445344452
4445444453MockFirebase.prototype.once = function (event, callback, cancel, context) {
@@ -44956,12 +44955,10 @@ MockFirestoreCollection.prototype.toString = function () {
4495644955 return this.path;
4495744956};
4495844957
44959- MockFirestoreCollection.defaultAutoId = function () {
44958+ MockFirestoreCollection.autoId = function () {
4496044959 return autoId(new Date().getTime());
4496144960};
4496244961
44963- MockFirestoreCollection.autoId = MockFirestoreCollection.defaultAutoId;
44964-
4496544962MockFirestoreCollection.prototype.add = function (data) {
4496644963 var err = this._nextErr('add');
4496744964 data = utils.cleanFirestoreData(data);
@@ -45134,7 +45131,7 @@ MockFirestoreDocument.prototype.getFlushQueue = function () {
4513445131 return this.queue.getEvents();
4513545132};
4513645133
45137- MockFirestoreDocument.prototype.getData = function () {
45134+ MockFirestoreDocument.prototype._getData = function () {
4513845135 return _.cloneDeep(this.data);
4513945136};
4514045137
@@ -45163,7 +45160,7 @@ MockFirestoreDocument.prototype.get = function () {
4516345160 return new Promise(function (resolve, reject) {
4516445161 self._defer('get', _.toArray(arguments), function () {
4516545162 if (err === null) {
45166- resolve(new DocumentSnapshot(self.id, self.ref, self.getData ()));
45163+ resolve(new DocumentSnapshot(self.id, self.ref, self._getData ()));
4516745164 } else {
4516845165 reject(err);
4516945166 }
@@ -45202,7 +45199,7 @@ MockFirestoreDocument.prototype._update = function (changes, opts, callback) {
4520245199 return new Promise(function (resolve, reject) {
4520345200 self._defer('update', _.toArray(arguments), function () {
4520445201 if (!err) {
45205- var base = self.getData ();
45202+ var base = self._getData ();
4520645203 var data;
4520745204 if (_opts.setMerge) {
4520845205 data = _.merge(_.isObject(base) ? base : {}, changes);
@@ -45411,7 +45408,7 @@ MockFirestoreQuery.prototype._setData = function (data) {
4541145408 this.data = utils.cleanFirestoreData(_.cloneDeep(data) || null);
4541245409};
4541345410
45414- MockFirestoreQuery.prototype.getData = function () {
45411+ MockFirestoreQuery.prototype._getData = function () {
4541545412 return _.cloneDeep(this.data);
4541645413};
4541745414
@@ -45496,14 +45493,14 @@ MockFirestoreQuery.prototype.where = function (property, operator, value) {
4549645493};
4549745494
4549845495MockFirestoreQuery.prototype.orderBy = function (property, direction) {
45499- var query = new MockFirestoreQuery(this.path, this.getData (), this.parent, this.id);
45496+ var query = new MockFirestoreQuery(this.path, this._getData (), this.parent, this.id);
4550045497 query.orderedProperties.push(property);
4550145498 query.orderedDirections.push(direction || 'asc');
4550245499 return query;
4550345500};
4550445501
4550545502MockFirestoreQuery.prototype.limit = function (limit) {
45506- var query = new MockFirestoreQuery(this.path, this.getData (), this.parent, this.id);
45503+ var query = new MockFirestoreQuery(this.path, this._getData (), this.parent, this.id);
4550745504 query.limited = limit;
4550845505 return query;
4550945506};
@@ -45541,7 +45538,6 @@ module.exports = MockFirestoreQuery;
4554145538var _ = require('./lodash');
4554245539var assert = require('assert');
4554345540var Promise = require('rsvp').Promise;
45544- var autoId = require('firebase-auto-ids');
4554545541var CollectionReference = require('./firestore-collection');
4554645542var DocumentReference = require('./firestore-document');
4554745543var FieldValue = require('./firestore-field-value');
@@ -45565,11 +45561,6 @@ function MockFirestore(path, data, parent, name) {
4556545561 this.data = _.cloneDeep(data) || null;
4556645562}
4556745563
45568- MockFirestore.defaultAutoId = function () {
45569- return autoId(new Date().getTime());
45570- };
45571-
45572- MockFirestore.autoId = MockFirestore.defaultAutoId;
4557345564MockFirestore.FieldValue = FieldValue;
4557445565
4557545566MockFirestore.prototype.flush = function (delay) {
@@ -45597,10 +45588,6 @@ MockFirestore.prototype.getFlushQueue = function () {
4559745588 return this.queue.getEvents();
4559845589};
4559945590
45600- MockFirestore.prototype.getData = function () {
45601- return _.cloneDeep(this.data);
45602- };
45603-
4560445591MockFirestore.prototype.toString = function () {
4560545592 return this.path;
4560645593};
@@ -45729,7 +45716,7 @@ function extractName(path) {
4572945716
4573045717module.exports = MockFirestore;
4573145718
45732- },{"./firestore-collection":48,"./firestore-document":51,"./firestore-field-value":52,"./lodash":56,"./queue":59,"./utils":68,"./validators":69,"assert":1,"firebase-auto-ids":5," rsvp":41}],56:[function(require,module,exports){
45719+ },{"./firestore-collection":48,"./firestore-document":51,"./firestore-field-value":52,"./lodash":56,"./queue":59,"./utils":68,"./validators":69,"assert":1,"rsvp":41}],56:[function(require,module,exports){
4573345720module.exports = {
4573445721 assign: require('lodash.assign'),
4573545722 bind: require('lodash.bind'),
@@ -47033,6 +47020,13 @@ exports.findUndefinedProperties = function (obj) {
4703347020 return results;
4703447021};
4703547022
47023+ exports.createThenableReference = function(reference, promise) {
47024+ reference.then = function(success, failure) {
47025+ return promise.then(success).catch(failure);
47026+ };
47027+ return reference;
47028+ };
47029+
4703647030},{"./firestore-field-value":52,"./lodash":56,"./snapshot":62}],69:[function(require,module,exports){
4703747031'use strict';
4703847032
0 commit comments