diff --git a/bower.json b/bower.json index f710246..d8365a1 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "firebase-mock", - "version": "2.3.5", + "version": "2.3.6", "homepage": "https://github.com/soumak77/firebase-mock", "authors": [ "Kato" diff --git a/browser/firebasemock.js b/browser/firebasemock.js index 97186bf..1b11ea2 100644 --- a/browser/firebasemock.js +++ b/browser/firebasemock.js @@ -1,4 +1,4 @@ -/** firebase-mock - v2.3.5 +/** firebase-mock - v2.3.6 https://github.com/dmurvihill/firebase-mock * Copyright (c) 2016 Brian Soumakian * License: MIT */ @@ -56696,10 +56696,11 @@ MockFirestoreDocument.prototype.create = function (data, callback) { }; MockFirestoreDocument.prototype.set = function (data, opts, callback) { - const writeTime = new Timestamp(Math.floor(Date.now() / 1000), 0); + var serverTime = utils.getServerTime(); + var result = new WriteResult(Timestamp.fromMillis(serverTime)); var _opts = _.assign({}, { merge: false }, opts); if (_opts.merge) { - return this._update(data, { setMerge: true }, callback).then(() => ({ writeTime })); + return this._update(data, { setMerge: true }, callback).then(() => (result)); } var err = this._nextErr('set'); data = _.cloneDeep(data); @@ -56709,7 +56710,7 @@ MockFirestoreDocument.prototype.set = function (data, opts, callback) { if (err === null) { data = utils.removeEmptyFirestoreProperties(data, utils.getServerTime()); self._dataChanged(data); - resolve({ writeTime }); + resolve(result); } else { if (callback) { callback(err); @@ -57367,6 +57368,7 @@ var FieldValue = require('./firestore-field-value'); var Queue = require('./queue').Queue; var Timestamp = require('./timestamp'); var utils = require('./utils'); +var WriteResult = require('./write-result'); var validate = require('./validators'); var DEFAULT_PATH = 'Mock://'; @@ -57446,7 +57448,8 @@ MockFirestore.prototype.runTransaction = function(transFunc) { var processBatchQueue = function (queue) { return Promise.all(_.map(queue, (queueItem) => { return new Promise((resolve) => { - const writeTime = new Timestamp(Math.floor(Date.now() / 1000), 0); + var serverTime = utils.getServerTime(); + var result = new WriteResult(Timestamp.fromMillis(serverTime)); var method = queueItem.method; var doc = queueItem.args[0]; var data = queueItem.args[1]; @@ -57455,20 +57458,20 @@ var processBatchQueue = function (queue) { if (method === 'set') { if (opts && opts.merge === true) { return doc._update(data, { setMerge: true }) - .then(resolve({ writeTime })); + .then(resolve(result)); } else { return doc.set(data) - .then(resolve({ writeTime })); + .then(resolve(result)); } } else if (method === 'create') { return doc.create(data) - .then(resolve({ writeTime })); + .then(resolve(result)); } else if (method === 'update') { return doc.update(data) - .then(resolve({ writeTime })); + .then(resolve(result)); } else if (method === 'delete') { return doc.delete() - .then(resolve({ writeTime })); + .then(resolve(result)); } return resolve(); @@ -57497,11 +57500,11 @@ MockFirestore.prototype.batch = function () { return batch; }, commit: function() { - const commited = processBatchQueue(queue); + const committed = processBatchQueue(queue); if (self.queue.events.length > 0) { self.flush(); } - return Promise.resolve(commited); + return Promise.resolve(committed); } }; return batch; @@ -57592,7 +57595,7 @@ function extractName(path) { module.exports = MockFirestore; -},{"./firestore-collection":84,"./firestore-document":87,"./firestore-field-path":88,"./firestore-field-value":89,"./lodash":93,"./queue":96,"./timestamp":104,"./utils":106,"./validators":107,"assert":1,"rsvp":74}],93:[function(require,module,exports){ +},{"./firestore-collection":84,"./firestore-document":87,"./firestore-field-path":88,"./firestore-field-value":89,"./lodash":93,"./queue":96,"./timestamp":104,"./utils":106,"./validators":107,"./write-result":108,"assert":1,"rsvp":74}],93:[function(require,module,exports){ module.exports = { assign: require('lodash.assign'), bind: require('lodash.bind'), diff --git a/package.json b/package.json index 050b016..f5e23e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "firebase-mock", - "version": "2.3.5", + "version": "2.3.6", "description": "Firebase mock library for writing unit tests", "scripts": { "hmm": "gulp hmm", diff --git a/yarn.lock b/yarn.lock index 3e828e6..e5bddab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3,7 +3,7 @@ "@sinonjs/commons@^1", "@sinonjs/commons@^1.3.0", "@sinonjs/commons@^1.7.0": - version "2.3.5" + version "2.3.6" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.6.tgz#80c516a4dc264c2a69115e7578d62581ff455ed9" integrity sha512-Ky+XkAkqPZSm3NLBeUng77EBQl3cmeJhITaGHdYH8kjVB+aun3S4XBRti2zt17mtt0mIUDiNxYeoJm6drVvBJQ== dependencies: