From b5d5f312a078cb41f3d297863bd67df332a5e265 Mon Sep 17 00:00:00 2001 From: Scott Prue Date: Mon, 25 Nov 2019 11:41:46 -0500 Subject: [PATCH] v0.11.0 * feat(core): add snapshot cache - #203 - @illuminist * fix(query): fix uncaught error when using populates - #250 * chore(test): start tests for populate - #250 * fix(orderedReducer): preserve id on document for `DOCUMENT_MODIFIED` action - #252 * fix(test): add a test to cover preserving of id for `DOCUMENT_MODIFIED` action - #252 * build(deps): bump mixin-deep from 1.3.1 to 1.3.2 - @dependabot --- examples/complete/package.json | 2 +- examples/complete/src/config.js | 8 +- examples/complete/yarn.lock | 348 +++++++++++----------- package-lock.json | 14 +- package.json | 4 +- src/actions/firestore.js | 17 +- src/index.js | 3 + src/reducers/orderedReducer.js | 9 +- src/utils/query.js | 41 ++- test/unit/actions/firestore.spec.js | 16 + test/unit/reducers/orderedReducer.spec.js | 19 +- test/unit/utils/query.spec.js | 43 ++- 12 files changed, 315 insertions(+), 209 deletions(-) diff --git a/examples/complete/package.json b/examples/complete/package.json index 33634f43..370bdd28 100644 --- a/examples/complete/package.json +++ b/examples/complete/package.json @@ -27,7 +27,7 @@ "dependencies": { "@material-ui/core": "^4.5.2", "@material-ui/icons": "^4.5.1", - "firebase": "^7.2.3", + "firebase": "^7.5.0", "history": "^4.10.1", "lodash": "^4.17.15", "prop-types": "^15.7.2", diff --git a/examples/complete/src/config.js b/examples/complete/src/config.js index 236bf78e..9ccfaa59 100644 --- a/examples/complete/src/config.js +++ b/examples/complete/src/config.js @@ -9,10 +9,10 @@ export const env = 'dev' // Config for firebase export const firebase = { apiKey: 'AIzaSyBTvAcJwsN8iygsnwAZyzIuy1uleYEpWIo', - authDomain: 'redux-firebasev3.firebaseapp.com', - databaseURL: 'https://redux-firebasev3.firebaseio.com', - projectId: 'redux-firebasev3', - storageBucket: 'redux-firebasev3.appspot.com' + authDomain: 'redux-firestore.firebaseapp.com', + databaseURL: 'https://redux-firestore.firebaseio.com', + projectId: 'redux-firestore', + storageBucket: 'redux-firestore.appspot.com' } // Config to override default reduxFirebase config in store/createStore diff --git a/examples/complete/yarn.lock b/examples/complete/yarn.lock index ab6b1be5..f2f4bc36 100644 --- a/examples/complete/yarn.lock +++ b/examples/complete/yarn.lock @@ -920,202 +920,202 @@ resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.7.3.tgz#a166882c81c0c6040975dd30df24fae8549bd96f" integrity sha512-14ZVlsB9akwvydAdaEnVnvqu6J2P6ySv39hYyl/aoB6w/V+bXX0tay8cF6paqbgZsN2n5Xh15uF4pE+GvE+itw== -"@firebase/analytics-types@0.2.2": - version "0.2.2" - resolved "https://registry.yarnpkg.com/@firebase/analytics-types/-/analytics-types-0.2.2.tgz#d442d0cda78dd5a43fe08441423d391b713987c8" - integrity sha512-5qLwkztNdRiLMQCsxmol1FxfGddb9xpensM2y++3rv1e0L4yI+MRR9SHSC00i847tGZDrMt2u67Dyko/xmrgCA== +"@firebase/analytics-types@0.2.3": + version "0.2.3" + resolved "https://registry.yarnpkg.com/@firebase/analytics-types/-/analytics-types-0.2.3.tgz#a160bf439cfefd74b22913e6e47d4377fb9c3372" + integrity sha512-8R8V5ZZsg6lDe2EiqgNq3XMQpAHbfStoXqRjdxu7FVCNLb/yxBThANdFXHbh4XxDc7vJEZr90PAjRB+bfGkSyw== -"@firebase/analytics@0.2.4": - version "0.2.4" - resolved "https://registry.yarnpkg.com/@firebase/analytics/-/analytics-0.2.4.tgz#d10cedee8d346c27f6eaa1ad94ee1a800657a01d" - integrity sha512-sipS72tA93+hopwXs1uuwK0RNJvx2jHxEUWkTZZ39KlsHhqHGiY4f9o1qiigN8b2ujJUf2Vf70CGXAKKLC/OWA== +"@firebase/analytics@0.2.7": + version "0.2.7" + resolved "https://registry.yarnpkg.com/@firebase/analytics/-/analytics-0.2.7.tgz#8f64acc4c155ab601976856f8fe6d1f568c03e39" + integrity sha512-ZpGvppEOk4qID5PZiPyGi5v+LFnXkbknMBm2ARisph1iesmxwgSHhn3QlqghjdVbdxONV2y4YSVUkJNCxCtX9A== dependencies: - "@firebase/analytics-types" "0.2.2" - "@firebase/installations" "0.3.3" - "@firebase/util" "0.2.31" + "@firebase/analytics-types" "0.2.3" + "@firebase/installations" "0.3.6" + "@firebase/util" "0.2.34" tslib "1.10.0" -"@firebase/app-types@0.4.7": - version "0.4.7" - resolved "https://registry.yarnpkg.com/@firebase/app-types/-/app-types-0.4.7.tgz#792a0f117185e42ec5a247f6bedc94a921711110" - integrity sha512-4LnhDYsUhgxMBnCfQtWvrmMy9XxeZo059HiRbpt3ufdpUcZZOBDOouQdjkODwHLhcnNrB7LeyiqYpS2jrLT8Mw== +"@firebase/app-types@0.4.8": + version "0.4.8" + resolved "https://registry.yarnpkg.com/@firebase/app-types/-/app-types-0.4.8.tgz#be69cbf3a7550c900d7af943adb2a3d1dcce6631" + integrity sha512-VTjWRooelMExK/rKArp6WqnWJJfi8Vs6VuDYDSeMcQ3NpSux2bW1dfJFuzYmiK1+37hEJP1F43DyUDv2lCJquw== -"@firebase/app@0.4.22": - version "0.4.22" - resolved "https://registry.yarnpkg.com/@firebase/app/-/app-0.4.22.tgz#0d5b73ffa279f0866b7e5c14bbd5078e68bcb593" - integrity sha512-XHf2vpX8JtYc181Za+X3S4dTEVzdFu17N9DfngsnO+2U4QcrUARFtClBOzCXjbyiJVPt5A8QjYJV49Wi3sqyig== +"@firebase/app@0.4.25": + version "0.4.25" + resolved "https://registry.yarnpkg.com/@firebase/app/-/app-0.4.25.tgz#b55a3e6516d3fba2a4e4198bb498ceb0259fbe72" + integrity sha512-Zf7RsWJhJXqWJ8tp1NQXFTYoEeURVkA+yI6On0SmPAxUo2CG1sXGhUt0TJBnYpKQLeDbhxVx552U85iMaVkvkw== dependencies: - "@firebase/app-types" "0.4.7" - "@firebase/logger" "0.1.28" - "@firebase/util" "0.2.31" + "@firebase/app-types" "0.4.8" + "@firebase/logger" "0.1.31" + "@firebase/util" "0.2.34" dom-storage "2.1.0" tslib "1.10.0" xmlhttprequest "1.8.0" -"@firebase/auth-types@0.8.2": - version "0.8.2" - resolved "https://registry.yarnpkg.com/@firebase/auth-types/-/auth-types-0.8.2.tgz#9722138481724a16a79f7d645e9c5598cc932269" - integrity sha512-qcP7wZ76CIb7IN+K544GomA42cCS36KZmQ3n9Ou1JsYplEaMo52x4UuQTZFqlRoMaUWi61oQ9jiuE5tOAMJwDA== +"@firebase/auth-types@0.9.1": + version "0.9.1" + resolved "https://registry.yarnpkg.com/@firebase/auth-types/-/auth-types-0.9.1.tgz#988cc0b5807ec20d56eaa6262f5fa317f9138a35" + integrity sha512-3P+qkJHkPcbyF9mubHGC4Bz2uZ6ha647rhWi3eMihXdD6E+vTEGpAi/KOp6KYvZJRbGbuCrobP61Djay1PuFlA== -"@firebase/auth@0.12.3": - version "0.12.3" - resolved "https://registry.yarnpkg.com/@firebase/auth/-/auth-0.12.3.tgz#c23573a997d3986784904833249de7e7c1eaa98c" - integrity sha512-w4bDznykC4rJIq/Zk8AxB+tpTi5/HT+ti0yLyoyPihLRulWVz4HVB9zghQfeyqMPoBGH1YtwaiZWG7Kk9Tyo8Q== +"@firebase/auth@0.13.1": + version "0.13.1" + resolved "https://registry.yarnpkg.com/@firebase/auth/-/auth-0.13.1.tgz#4a205f5f84ac2b3c87d9cae41b7ca2d5a037376f" + integrity sha512-JN/850MuahGea7NZMVbNTl3ASGFqSt8Hx9DuP4s0XZ1U0FcA439nSKGxjD0phn/HpwzYyU+sMxh1gmffuyWKMw== dependencies: - "@firebase/auth-types" "0.8.2" + "@firebase/auth-types" "0.9.1" -"@firebase/database-types@0.4.7": - version "0.4.7" - resolved "https://registry.yarnpkg.com/@firebase/database-types/-/database-types-0.4.7.tgz#9fc82b3895fc096f073e37dd66d6e5b32f233a54" - integrity sha512-7UHZ0n6aj3sR5W4HsU18dysHMSIS6348xWTMypoA0G4mORaQSuleCSL6zJLaCosarDEojnncy06yW69fyFxZtA== +"@firebase/database-types@0.4.8": + version "0.4.8" + resolved "https://registry.yarnpkg.com/@firebase/database-types/-/database-types-0.4.8.tgz#ec225ac9e37a31cb0aa827b86d0073dfdc5289f1" + integrity sha512-bYGzvcwjGOSWuL43nldY3kD3ldPDLTiiOF0TItsJx2JdL58PzGiGaR71dvPJhueNBn+bwJ5KPJxpqTSVqM/j8w== dependencies: - "@firebase/app-types" "0.4.7" + "@firebase/app-types" "0.4.8" -"@firebase/database@0.5.10": - version "0.5.10" - resolved "https://registry.yarnpkg.com/@firebase/database/-/database-0.5.10.tgz#390256ea791e7ae7de174f50311e18c558beb895" - integrity sha512-bzQAWYYH1byh9G6OTYAuTSvTeODyJ60QaL92dVtfnZGh7UQDsluTJ9iivH/ev7PJt43tYqI+2VmrEhbtrr/Zow== +"@firebase/database@0.5.13": + version "0.5.13" + resolved "https://registry.yarnpkg.com/@firebase/database/-/database-0.5.13.tgz#1d8296d15efefeafe26877f9753fe1f283a0ec63" + integrity sha512-B1+6Ns3jbpryDUi6ZohByXk8EPcuD5rUla1UchzdCjsU1waq06QyUrakow5Hr5RugqmziMAOfzpXid+wV4+bvw== dependencies: - "@firebase/database-types" "0.4.7" - "@firebase/logger" "0.1.28" - "@firebase/util" "0.2.31" + "@firebase/database-types" "0.4.8" + "@firebase/logger" "0.1.31" + "@firebase/util" "0.2.34" faye-websocket "0.11.3" tslib "1.10.0" -"@firebase/firestore-types@1.6.2": - version "1.6.2" - resolved "https://registry.yarnpkg.com/@firebase/firestore-types/-/firestore-types-1.6.2.tgz#3e65d18ee552384504fb85ba691df7bec0721e97" - integrity sha512-GsBlAqNft1pwEWNKnQWwwqzLoyfUSC3bSb1e7yxu5+NKaJO+uUD48KrZUTDu94pgPLkJslj8SLkl9FVjNJa8Xw== +"@firebase/firestore-types@1.8.0": + version "1.8.0" + resolved "https://registry.yarnpkg.com/@firebase/firestore-types/-/firestore-types-1.8.0.tgz#4d8bd14c7c4496f7f317ee52d1487f6dca8dc7f1" + integrity sha512-Zy7IDqtjZPbKB6tP4dKuNks3tCvWOa3VhqEdl4WLyMKhvqh+/d0lzr+0HEEeEWR4IogsnJmLZUjDx0eqvqfCpg== -"@firebase/firestore@1.6.4": - version "1.6.4" - resolved "https://registry.yarnpkg.com/@firebase/firestore/-/firestore-1.6.4.tgz#0f7664c5bcc1af0326cc56541aac7d4d23d7e9fb" - integrity sha512-qASkdJgA6oryJAE6H+LewXLxLW6XYl7qIylQW/vJAAZZed5N4+h89qdE3PXGHA61lEe+kdYidskvn9rJQGINgw== +"@firebase/firestore@1.8.0": + version "1.8.0" + resolved "https://registry.yarnpkg.com/@firebase/firestore/-/firestore-1.8.0.tgz#16fc09cb2a871115997de700a77b1e1c72ef44f3" + integrity sha512-MOuM2Bpgq9b+GnMJL9ui8aIwTTCSZ0u+qG2R7O8NoQogvB/XDCDjPER7PJfLLZ03yxiSuWKiJ+pu37AqgDIxhg== dependencies: - "@firebase/firestore-types" "1.6.2" - "@firebase/logger" "0.1.28" - "@firebase/util" "0.2.31" - "@firebase/webchannel-wrapper" "0.2.29" + "@firebase/firestore-types" "1.8.0" + "@firebase/logger" "0.1.31" + "@firebase/util" "0.2.34" + "@firebase/webchannel-wrapper" "0.2.32" "@grpc/proto-loader" "^0.5.0" - grpc "1.24.1" + grpc "1.24.2" tslib "1.10.0" -"@firebase/functions-types@0.3.10": - version "0.3.10" - resolved "https://registry.yarnpkg.com/@firebase/functions-types/-/functions-types-0.3.10.tgz#9ac1bfed56bf4e968d8c2daa12d7d935bcac9fc4" - integrity sha512-QDh7HOxfUzLxj49szekgXxdkXz6ZwwK/63DKeDbRYMKzxo17I01+2GVisdBmUW5NkllVLgVvtOfqKbbEfndqdw== +"@firebase/functions-types@0.3.11": + version "0.3.11" + resolved "https://registry.yarnpkg.com/@firebase/functions-types/-/functions-types-0.3.11.tgz#11b42df4a50e3ceb176aec7a998840e6f6d9680f" + integrity sha512-sNLrBzTm6Rzq/QMbCgenhJW2LU+gQx0IMYZJJjz50dhYzQSfirlEdFEo8xm59aWhqCw87AI4XzNSGgu53C2OVA== -"@firebase/functions@0.4.23": - version "0.4.23" - resolved "https://registry.yarnpkg.com/@firebase/functions/-/functions-0.4.23.tgz#af9a38148de89f431e87d5e45d4819c6e0908ad4" - integrity sha512-QGnnNCgYOUhb1No5qYVjjMbkjBgnbBeF5rZ/eBzzLvLKtd9LjxIuxAXhOGMSHNLEngYWjiSZMJu2Nu+hED/ThA== +"@firebase/functions@0.4.26": + version "0.4.26" + resolved "https://registry.yarnpkg.com/@firebase/functions/-/functions-0.4.26.tgz#81887c0ff421479b3c3bd433f67a2dbb70171631" + integrity sha512-ZY3sWKdi7UuKhZ/P05AtzOwPNZCU4oSkpWc1UR+GcYvGtn54e8PVwFvhYBZpo9DyvEgDx/0uXrtMVRvqdYUmDg== dependencies: - "@firebase/functions-types" "0.3.10" - "@firebase/messaging-types" "0.3.4" + "@firebase/functions-types" "0.3.11" + "@firebase/messaging-types" "0.3.5" isomorphic-fetch "2.2.1" tslib "1.10.0" -"@firebase/installations-types@0.2.1": - version "0.2.1" - resolved "https://registry.yarnpkg.com/@firebase/installations-types/-/installations-types-0.2.1.tgz#83f79ed575f1fd3d973ab3b5180f16cb10647712" - integrity sha512-647hwBhMKOjoLndCyi9XmT1wnrRc2T8aGIAoZBqy7rxFqu3c9jZRk3THfufLy1xvAJC3qqYavETrRYF3VigM7Q== +"@firebase/installations-types@0.2.2": + version "0.2.2" + resolved "https://registry.yarnpkg.com/@firebase/installations-types/-/installations-types-0.2.2.tgz#a386665a7e0723e961a4bb4c8fa127b09c547732" + integrity sha512-ABe4pJbBPYTyUQZ/BzyMZw9VEO+XYrClsxcVZ3WJTlhiu1OuBOeFfdbbsKPlywqwS5cVSM0xO9bJSgiMWQhUfQ== -"@firebase/installations@0.3.3": - version "0.3.3" - resolved "https://registry.yarnpkg.com/@firebase/installations/-/installations-0.3.3.tgz#d73af10c8a1653d04e7f1412afafef26240f94ec" - integrity sha512-ay0FuP4ooqWzK+tLS6Nv/aOQ92exRbqzBinM9C4F21p/u66dvE3JTbRwRXQi+BjYi/Ofd4MMUrsZEc9/kOxxRg== +"@firebase/installations@0.3.6": + version "0.3.6" + resolved "https://registry.yarnpkg.com/@firebase/installations/-/installations-0.3.6.tgz#b205902243581e525083c88b22bf3aeb7e56fcd8" + integrity sha512-30RNzx8wBHm5RIPVVxdpSBGohPeOCl5YQ5qCdmx/gImokP9q4GC1i8BOKh/OldXiRY6nMVU2uzPaCpOSZsPFNw== dependencies: - "@firebase/installations-types" "0.2.1" - "@firebase/util" "0.2.31" + "@firebase/installations-types" "0.2.2" + "@firebase/util" "0.2.34" idb "3.0.2" tslib "1.10.0" -"@firebase/logger@0.1.28": - version "0.1.28" - resolved "https://registry.yarnpkg.com/@firebase/logger/-/logger-0.1.28.tgz#3a17ba99100d5edf100dbb42a05146e4d1b27246" - integrity sha512-bzCJ6v5JrgQdut+3R+t6hVU7O3QnV15ay+HA9ejATZqQfMtwewDAYendNRmSZBjoR8BcrVO490L4vVhPQJRJNw== +"@firebase/logger@0.1.31": + version "0.1.31" + resolved "https://registry.yarnpkg.com/@firebase/logger/-/logger-0.1.31.tgz#e0ab28af14333786952d7a5154f90d0453414d24" + integrity sha512-1OEJaCMMaaT0VleNwer3bocbd25beR6KZUaHBweLNHEFxaNvniSv+lm83g08dWLBml3ZVOb945hp6m8REFx6/Q== -"@firebase/messaging-types@0.3.4": - version "0.3.4" - resolved "https://registry.yarnpkg.com/@firebase/messaging-types/-/messaging-types-0.3.4.tgz#8154d731355194f8de9a6cbcd33b84c696b5f2ba" - integrity sha512-ytOzB08u8Z15clbq9cAjhFzUs4WRy13A7gRphjnf5rQ+gsrqb4mpcsGIp0KeOcu7MjcN9fqjO5nbVaw0t2KJpQ== +"@firebase/messaging-types@0.3.5": + version "0.3.5" + resolved "https://registry.yarnpkg.com/@firebase/messaging-types/-/messaging-types-0.3.5.tgz#92fcd3d6a91116afead63bc7bebebe78162b6c63" + integrity sha512-pRhKJlE/eXc6uBGCmi7BjBen427lbIVlxUH9aKpu5Nrd8nUQ507WwVVL098A0oY0Kx2AJxjwjmtDjDYCaFm9Hg== -"@firebase/messaging@0.5.4": - version "0.5.4" - resolved "https://registry.yarnpkg.com/@firebase/messaging/-/messaging-0.5.4.tgz#16c7a1012c2f82713788e9c7232bdd95077129a8" - integrity sha512-RF6n/03mwkjNsKMhX9DB0jausb39CScGKiUGTVT/d+rj6Lk1l3JGJGMVYkdJ339hyV9EwbGzFTYRfkehSJEBTA== +"@firebase/messaging@0.5.7": + version "0.5.7" + resolved "https://registry.yarnpkg.com/@firebase/messaging/-/messaging-0.5.7.tgz#294b15a2f50ab1922742e8fca5160de03d7d4231" + integrity sha512-JQLhHCo6THIzj74/iGrAxJY3YI05+q9UlHAykr8HkDtmNjFkiVCGLcuCrYcwayvElziGGQ3EQAD+EGAN1BkjCw== dependencies: - "@firebase/installations" "0.3.3" - "@firebase/messaging-types" "0.3.4" - "@firebase/util" "0.2.31" + "@firebase/installations" "0.3.6" + "@firebase/messaging-types" "0.3.5" + "@firebase/util" "0.2.34" tslib "1.10.0" -"@firebase/performance-types@0.0.5": - version "0.0.5" - resolved "https://registry.yarnpkg.com/@firebase/performance-types/-/performance-types-0.0.5.tgz#8576af338ef1890bce57fbd7cd1c99ef65cedf4b" - integrity sha512-7BOQ2sZZzaIvxscgan/uP8GcH2FZXzqGcQnXvUZBXfXignAM80hJ7UOjVRETa4UjtDehWcD/pZDDivupKtKUyg== - -"@firebase/performance@0.2.23": - version "0.2.23" - resolved "https://registry.yarnpkg.com/@firebase/performance/-/performance-0.2.23.tgz#bfdae1e0e6c0d5a8eeefbbfda3ed53b253e5a65f" - integrity sha512-Yf861DZ2F0FCuVX6ukrtjWB4jrP2xvp6W1coCDrxJxnRuvTpapE5U7oxYotXslPTRnoLOgfgMLxj2UYxXoA/mw== - dependencies: - "@firebase/installations" "0.3.3" - "@firebase/logger" "0.1.28" - "@firebase/performance-types" "0.0.5" - "@firebase/util" "0.2.31" +"@firebase/performance-types@0.0.6": + version "0.0.6" + resolved "https://registry.yarnpkg.com/@firebase/performance-types/-/performance-types-0.0.6.tgz#c588bec1fda4928659772988b4f7cbe1c4434bb8" + integrity sha512-nfiIWBuMVXj+G+xIQwpwQjFhtY85GnywAL1S/CTEMTe6tgc9nA+x9ycFU2rEIl3XVTeaHqs616pe1gYToGpRJQ== + +"@firebase/performance@0.2.26": + version "0.2.26" + resolved "https://registry.yarnpkg.com/@firebase/performance/-/performance-0.2.26.tgz#8d0595e8b7e18128812a2174bff47b3a77dae83c" + integrity sha512-xQpdBv3dygt7y/mMkixPL9ty1YzTyGyVvazub1QNBqzEyIVRI7Slg03taFQ6551x+JPWmmyUCqH6+dQ4U2+HHg== + dependencies: + "@firebase/installations" "0.3.6" + "@firebase/logger" "0.1.31" + "@firebase/performance-types" "0.0.6" + "@firebase/util" "0.2.34" tslib "1.10.0" -"@firebase/polyfill@0.3.26": - version "0.3.26" - resolved "https://registry.yarnpkg.com/@firebase/polyfill/-/polyfill-0.3.26.tgz#05d27baaa70c4b27ec123dbd6e5858fcf948d786" - integrity sha512-x3dyOQG7E0Pfaw0UuevXBOsjX/etTwCVMbEXPtzLKsaV7woB/6aep2iz16YC7s5vgShUGkwrQwvP+S6rcnu1Fw== +"@firebase/polyfill@0.3.29": + version "0.3.29" + resolved "https://registry.yarnpkg.com/@firebase/polyfill/-/polyfill-0.3.29.tgz#0a7df47780407c16fb29951acee6c55afe6578a2" + integrity sha512-Ogc6BUYoyOb64lFAGBjMydoczSHdazMeINTBjEEfSkaDqOi7l/tgk9X+oWYe5mxfPNrdBLREkfQb6oKqFPqydQ== dependencies: - core-js "3.3.3" + core-js "3.4.1" promise-polyfill "8.1.3" whatwg-fetch "2.0.4" -"@firebase/remote-config-types@0.1.2": - version "0.1.2" - resolved "https://registry.yarnpkg.com/@firebase/remote-config-types/-/remote-config-types-0.1.2.tgz#056f30e9ba400cc191978bf5138ee4e11ab0d123" - integrity sha512-V1LutCn9fHC5ckkjJFGGB7z72xdg50RVaCkR80x4iJXqac0IpbEr1/k29HSPKiAlf+aIYyj6gFzl7gn4ZzsUcA== +"@firebase/remote-config-types@0.1.3": + version "0.1.3" + resolved "https://registry.yarnpkg.com/@firebase/remote-config-types/-/remote-config-types-0.1.3.tgz#9ea39aa71dc88dcd9a80889eacfe66699e85a8ce" + integrity sha512-5niKHAHDEaTF6Ch7Jc91WNCy3ZdKEjYlq0l6tDTyjN0lHp6qJW1IKdS3ExBBRmpqP8vjQOUxSDiIPbIZV3ncHw== -"@firebase/remote-config@0.1.4": - version "0.1.4" - resolved "https://registry.yarnpkg.com/@firebase/remote-config/-/remote-config-0.1.4.tgz#acdc4da904c73958d61b59c8f531ad6730580bae" - integrity sha512-CbwHb24MtocbNcYEoDX6sdiBd8kbTS5bIKFJy6YCsrvf24baPOsq7Hl2FpYcie+HGcy6Fce3VfLKbEzR6Y8nvA== +"@firebase/remote-config@0.1.7": + version "0.1.7" + resolved "https://registry.yarnpkg.com/@firebase/remote-config/-/remote-config-0.1.7.tgz#3fc89e608bae5fab03a1cd68e0fe96209fda2f3a" + integrity sha512-v//JIZZSMwPPuHDK+SmcBPA02UTYT2NiDa+4U42Di2iFG5Q9nlOkrxHIOx6Qqr1t7gDqgC1qBRYBeorTpxbTeA== dependencies: - "@firebase/installations" "0.3.3" - "@firebase/logger" "0.1.28" - "@firebase/remote-config-types" "0.1.2" - "@firebase/util" "0.2.31" + "@firebase/installations" "0.3.6" + "@firebase/logger" "0.1.31" + "@firebase/remote-config-types" "0.1.3" + "@firebase/util" "0.2.34" tslib "1.10.0" -"@firebase/storage-types@0.3.5": - version "0.3.5" - resolved "https://registry.yarnpkg.com/@firebase/storage-types/-/storage-types-0.3.5.tgz#c8bce8b09fa5937cb55a77b5549237ebc66fd996" - integrity sha512-rbG6ge3xmte0nUt0asMToPqmNRU4tCJuu73Uy0UJV4uMBQA7e27EXbPza3nBpeOrgASBV9eWPD5AzecjBvTyzQ== +"@firebase/storage-types@0.3.6": + version "0.3.6" + resolved "https://registry.yarnpkg.com/@firebase/storage-types/-/storage-types-0.3.6.tgz#9cbbbe65e1b0d19f7bfdb4d5e684e8d26e202057" + integrity sha512-yHsYhaFQMryR/lgXIdm1mMQwmyC76HLpQHtAxB5WF9FzwjXishJTn1Qe0+JuSWmlHmYXI3EyrCr/JUAv2OS1wQ== -"@firebase/storage@0.3.17": - version "0.3.17" - resolved "https://registry.yarnpkg.com/@firebase/storage/-/storage-0.3.17.tgz#7e5376821a77fa60213b37fa0dd71b20e1514a40" - integrity sha512-VUjNHqxKtCKmujxYvAv6UUJutFBnMhNDjvXM01QZavDbqjUF0Q6MQ9asFm3uLDvUO8EonACWw3dExG2MVdKB/A== +"@firebase/storage@0.3.20": + version "0.3.20" + resolved "https://registry.yarnpkg.com/@firebase/storage/-/storage-0.3.20.tgz#62a56cda7e9885b9ece0669af231ff333862d864" + integrity sha512-aKZHC1M20rDKX8Xxkz5gBQgT1g0whk1rVeZaqCIrYyNsTbAEomzgodstFLtbXwhVsV+DwWzynm4G7WDoFpr4HA== dependencies: - "@firebase/storage-types" "0.3.5" - "@firebase/util" "0.2.31" + "@firebase/storage-types" "0.3.6" + "@firebase/util" "0.2.34" tslib "1.10.0" -"@firebase/util@0.2.31": - version "0.2.31" - resolved "https://registry.yarnpkg.com/@firebase/util/-/util-0.2.31.tgz#f5e1b75e38a8f5696c84667b6e94f513c3476e0b" - integrity sha512-Iv+M2oluKHgDux5PqKFy8VtujO/1gOURmWKVLXyVLnrZKAFrU6etdBeWA1n+eXLnGJzreQF1JD9k8caMDD7CoQ== +"@firebase/util@0.2.34": + version "0.2.34" + resolved "https://registry.yarnpkg.com/@firebase/util/-/util-0.2.34.tgz#a84fc09a68e82012b650964944e8ffc956ec4912" + integrity sha512-k8pNIzNLncvxDrqYVZN6/lnqZWy0OCJuZmK5urodARwdLy3sVLw5p9PWce0v9qzMO8tLdrBbCpnm1KJ8jg/kBQ== dependencies: tslib "1.10.0" -"@firebase/webchannel-wrapper@0.2.29": - version "0.2.29" - resolved "https://registry.yarnpkg.com/@firebase/webchannel-wrapper/-/webchannel-wrapper-0.2.29.tgz#48abfc78e817d526e0a60e086347468447398574" - integrity sha512-veAoFK0EdzeGcoje7ssiMxoU3WBXuEP+TUPEbd6mqVhBECcLDCQrBQNU3e2Z05BWQMoDLKkLI+cSvkAr+En7bA== +"@firebase/webchannel-wrapper@0.2.32": + version "0.2.32" + resolved "https://registry.yarnpkg.com/@firebase/webchannel-wrapper/-/webchannel-wrapper-0.2.32.tgz#ae5e1c0dc6856d8b9ae192bc000e43b993acba68" + integrity sha512-kXnsBuzmtcOntliDgxAGJJ8JHPOmZ6KgS2v0/5Fb5KXpN9UIFyeaE8pfdkBG9tESdPmGdKpJz781fEIMdMtd8A== "@grpc/proto-loader@^0.5.0": version "0.5.2" @@ -3514,10 +3514,10 @@ core-js@3.2.1: resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.2.1.tgz#cd41f38534da6cc59f7db050fe67307de9868b09" integrity sha512-Qa5XSVefSVPRxy2XfUC13WbvqkxhkwB3ve+pgCQveNgYzbM/UxZeu1dcOX/xr4UmfUd+muuvsaxilQzCyUurMw== -core-js@3.3.3: - version "3.3.3" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.3.3.tgz#b7048d3c6c1a52b5fe55a729c1d4ccdffe0891bb" - integrity sha512-0xmD4vUJRY8nfLyV9zcpC17FtSie5STXzw+HyYw2t8IIvmDnbq7RJUULECCo+NstpJtwK9kx8S+898iyqgeUow== +core-js@3.4.1: + version "3.4.1" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.4.1.tgz#76dd6828412900ab27c8ce0b22e6114d7ce21b18" + integrity sha512-KX/dnuY/J8FtEwbnrzmAjUYgLqtk+cxM86hfG60LGiW3MmltIc2yAmDgBgEkfm0blZhUrdr1Zd84J2Y14mLxzg== core-js@^1.0.0: version "1.2.7" @@ -5213,25 +5213,25 @@ firebase-tools@^7.6.2: uuid "^3.0.0" winston "^1.0.1" -firebase@^7.2.3: - version "7.2.3" - resolved "https://registry.yarnpkg.com/firebase/-/firebase-7.2.3.tgz#44d8ca19dc5e04ffcc6d0cf2f4bd6fb544571a02" - integrity sha512-rLNyyRr/tz1kZLHnqk6S2zmWrGAT1zY4GJCdqrjViK9frUiVfyB1CqOTy/nvZqU4h+O2YGEcw3klqelsUbEVCw== - dependencies: - "@firebase/analytics" "0.2.4" - "@firebase/app" "0.4.22" - "@firebase/app-types" "0.4.7" - "@firebase/auth" "0.12.3" - "@firebase/database" "0.5.10" - "@firebase/firestore" "1.6.4" - "@firebase/functions" "0.4.23" - "@firebase/installations" "0.3.3" - "@firebase/messaging" "0.5.4" - "@firebase/performance" "0.2.23" - "@firebase/polyfill" "0.3.26" - "@firebase/remote-config" "0.1.4" - "@firebase/storage" "0.3.17" - "@firebase/util" "0.2.31" +firebase@^7.5.0: + version "7.5.0" + resolved "https://registry.yarnpkg.com/firebase/-/firebase-7.5.0.tgz#bd011eb37bd763896b001d9b72379f286ee1d351" + integrity sha512-1ymVJ9Xq9xE9uoQIwFO7yZY/fzUmjOkhkfsQPiQFaG9Ue0EUjZF7HP0NWFdJuYvgf7bLCI6IHJPA6EHbjQoVGw== + dependencies: + "@firebase/analytics" "0.2.7" + "@firebase/app" "0.4.25" + "@firebase/app-types" "0.4.8" + "@firebase/auth" "0.13.1" + "@firebase/database" "0.5.13" + "@firebase/firestore" "1.8.0" + "@firebase/functions" "0.4.26" + "@firebase/installations" "0.3.6" + "@firebase/messaging" "0.5.7" + "@firebase/performance" "0.2.26" + "@firebase/polyfill" "0.3.29" + "@firebase/remote-config" "0.1.7" + "@firebase/storage" "0.3.20" + "@firebase/util" "0.2.34" flat-arguments@^1.0.0: version "1.0.2" @@ -5704,16 +5704,16 @@ growly@^1.3.0: resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE= -grpc@1.24.1: - version "1.24.1" - resolved "https://registry.yarnpkg.com/grpc/-/grpc-1.24.1.tgz#0afefd6feeeb3d9ce09586f08400007ea6cb6a16" - integrity sha512-NFIWbt3RXZU4VlDLpiAM/Ca8Yz30QShUdPGMqOPH652PmA+2fau2vuW+tOYWQUkYMfBW2yege/T5p65e5TetVQ== +grpc@1.24.2: + version "1.24.2" + resolved "https://registry.yarnpkg.com/grpc/-/grpc-1.24.2.tgz#76d047bfa7b05b607cbbe3abb99065dcefe0c099" + integrity sha512-EG3WH6AWMVvAiV15d+lr+K77HJ/KV/3FvMpjKjulXHbTwgDZkhkcWbwhxFAoTdxTkQvy0WFcO3Nog50QBbHZWw== dependencies: "@types/bytebuffer" "^5.0.40" lodash.camelcase "^4.3.0" lodash.clone "^4.5.0" nan "^2.13.2" - node-pre-gyp "^0.13.0" + node-pre-gyp "^0.14.0" protobufjs "^5.0.3" gtoken@^1.2.1: @@ -8526,10 +8526,10 @@ node-pre-gyp@^0.12.0: semver "^5.3.0" tar "^4" -node-pre-gyp@^0.13.0: - version "0.13.0" - resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.13.0.tgz#df9ab7b68dd6498137717838e4f92a33fc9daa42" - integrity sha512-Md1D3xnEne8b/HGVQkZZwV27WUi1ZRuZBij24TNaZwUPU3ZAFtvT6xxJGaUVillfmMKnn5oD1HoGsp2Ftik7SQ== +node-pre-gyp@^0.14.0: + version "0.14.0" + resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.14.0.tgz#9a0596533b877289bcad4e143982ca3d904ddc83" + integrity sha512-+CvDC7ZttU/sSt9rFjix/P05iS43qHCOOGzcr3Ry99bXG7VX953+vFyEuph/tfqoYu8dttBkE86JSKBO2OzcxA== dependencies: detect-libc "^1.0.2" mkdirp "^0.5.1" @@ -8540,7 +8540,7 @@ node-pre-gyp@^0.13.0: rc "^1.2.7" rimraf "^2.6.1" semver "^5.3.0" - tar "^4" + tar "^4.4.2" node-releases@^1.1.29: version "1.1.35" @@ -12012,7 +12012,7 @@ tar@^2.0.0: fstream "^1.0.12" inherits "2" -tar@^4, tar@^4.3.0: +tar@^4, tar@^4.3.0, tar@^4.4.2: version "4.4.13" resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.13.tgz#43b364bc52888d555298637b10d60790254ab525" integrity sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA== diff --git a/package-lock.json b/package-lock.json index e01c2dba..3ef0cd8a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "redux-firestore", - "version": "0.10.0", + "version": "0.11.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -149,7 +149,7 @@ }, "minimist": { "version": "1.2.0", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true }, @@ -7386,9 +7386,9 @@ } }, "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha1-pJ5yaNzhoNlpjkUybFYm3zVD0P4=", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", "dev": true, "requires": { "for-in": "^1.0.2", @@ -7398,7 +7398,7 @@ "is-extendable": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha1-p0cPnkJnM9gb2B4RVSZOOjUHyrQ=", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, "requires": { "is-plain-object": "^2.0.4" @@ -9051,7 +9051,7 @@ "dependencies": { "jsesc": { "version": "0.5.0", - "resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", "dev": true } diff --git a/package.json b/package.json index d3b6badd..7aa5bae2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "redux-firestore", - "version": "0.10.0", + "version": "0.11.0", "description": "Redux bindings for Firestore.", "main": "lib/index.js", "module": "es/index.js", @@ -25,7 +25,7 @@ "watch:lib": "npm run build:lib -- --watch", "watch:commonjs": "npm run build:commonjs -- --watch", "test": "mocha -R spec ./test/unit/**", - "test:cov": "nyc mocha -R spec ./test/unit/** && nyc report --reporter=lcov", + "test:cov": "nyc --reporter=lcov --reporter=html npm run test", "codecov": "cat coverage/lcov.info | codecov", "lint": "eslint src test", "lint:fix": "npm run lint -- --fix", diff --git a/src/actions/firestore.js b/src/actions/firestore.js index 9f52647f..bcfd23cf 100644 --- a/src/actions/firestore.js +++ b/src/actions/firestore.js @@ -4,14 +4,15 @@ import { wrapInDispatch } from '../utils/actions'; import { actionTypes } from '../constants'; import { attachListener, - detachListener, - orderedFromSnap, dataByIdSnapshot, - getQueryConfig, - getQueryName, - firestoreRef, + detachListener, dispatchListenerResponse, + firestoreRef, getPopulateActions, + getQueryConfig, + getQueryName, + orderedFromSnap, + snapshotCache, } from '../utils/query'; const pathListenerCounts = {}; @@ -34,7 +35,11 @@ export function add(firebase, dispatch, queryOption, ...args) { actionTypes.ADD_REQUEST, { type: actionTypes.ADD_SUCCESS, - payload: snap => ({ id: snap.id, data: args[0] }), + payload: snap => { + const obj = { id: snap.id, data: args[0] }; + snapshotCache.set(obj, snap); + return obj; + }, }, actionTypes.ADD_FAILURE, ], diff --git a/src/index.js b/src/index.js index 78c9e154..2c5f0d1f 100644 --- a/src/index.js +++ b/src/index.js @@ -4,6 +4,7 @@ import { firestoreActions } from './actions'; import createFirestoreInstance from './createFirestoreInstance'; import constants, { actionTypes } from './constants'; import middleware, { CALL_FIRESTORE } from './middleware'; +import { getSnapshotByObject } from './utils/query'; // converted with transform-inline-environment-variables export const version = process.env.npm_package_version; @@ -16,6 +17,7 @@ export { createFirestoreInstance, firestoreActions as actions, getFirestore, + getSnapshotByObject, constants, actionTypes, middleware, @@ -31,6 +33,7 @@ export default { createFirestoreInstance, actions: firestoreActions, getFirestore, + getSnapshotByObject, constants, actionTypes, middleware, diff --git a/src/reducers/orderedReducer.js b/src/reducers/orderedReducer.js index 971d17b8..7ba867b7 100644 --- a/src/reducers/orderedReducer.js +++ b/src/reducers/orderedReducer.js @@ -66,12 +66,9 @@ function modifyDoc(collectionState, action) { } if (!action.meta.subcollections || action.meta.storeAs) { - return updateItemInArray( - collectionState, - action.meta.doc, - item => - // Merge is no longer used to prevent removal of subcollections since this will change in v1 - action.payload.data, + return updateItemInArray(collectionState, action.meta.doc, item => + // Merge is no longer used to prevent removal of subcollections since this will change in v1 + ({ id: action.meta.doc, ...action.payload.data }), ); } diff --git a/src/utils/query.js b/src/utils/query.js index 4cde3fa0..730c1e23 100644 --- a/src/utils/query.js +++ b/src/utils/query.js @@ -12,6 +12,23 @@ import { } from 'lodash'; import { actionTypes } from '../constants'; +export const snapshotCache = new WeakMap(); +/** + * Get DocumentSnapshot and QuerySnapshot with object from either data or + * ordered firestore state. If provided with doc data, it will return + * DocumentSnapshot, providing with a collection from data or an array from + * ordered state will return QuerySnapshot, except ordered state that generated + * as DocumentRef will return DocumentSnapshot + * Note: the cache is local and, not persistance. Passing an object from initial + * state or from SSR state will yield undefined. + * @param {object|Array} obj - The object from data or ordered state + * @returns {firebase.firestore.DocumentSnapshot|firebase.firestore.QuerySnapshot} + * DocumentSnapshot or QuerySnapshot depend on type of object provided + */ +export function getSnapshotByObject(obj) { + return snapshotCache.get(obj); +} + /** * Add where claues to Cloud Firestore Reference handling invalid formats * and multiple where statements (array of arrays) @@ -443,15 +460,18 @@ export function orderedFromSnap(snap) { const obj = isObject(snap.data()) ? { id: snap.id, ...(snap.data() || snap.data) } : { id: snap.id, data: snap.data() }; + snapshotCache.set(obj, snap); ordered.push(obj); } else if (snap.forEach) { snap.forEach(doc => { const obj = isObject(doc.data()) ? { id: doc.id, ...(doc.data() || doc.data) } : { id: doc.id, data: doc.data() }; + snapshotCache.set(obj, snap); ordered.push(obj); }); } + snapshotCache.set(ordered, snap); return ordered; } @@ -464,13 +484,23 @@ export function orderedFromSnap(snap) { export function dataByIdSnapshot(snap) { const data = {}; if (snap.data) { - data[snap.id] = snap.exists ? snap.data() : null; + const snapData = snap.exists ? snap.data() : null; + if (snapData) { + snapshotCache.set(snapData, snap); + } + data[snap.id] = snapData; } else if (snap.forEach) { snap.forEach(doc => { - data[doc.id] = doc.data() || doc; + const snapData = doc.data() || doc; + snapshotCache.set(snapData, snap); + data[doc.id] = snapData; }); } - return !!data && Object.keys(data).length ? data : null; + if (!!data && Object.keys(data).length) { + snapshotCache.set(data, snap); + return data; + } + return null; } /** @@ -571,9 +601,8 @@ export function promisesForPopulate( : populatesIn, ); - const dataHasPopulateChilds = populatesForData.some( - populatesForData, - populate => has(originalData, populate.child), + const dataHasPopulateChilds = populatesForData.some(populate => + has(originalData, populate.child), ); if (dataHasPopulateChilds) { // Data is a single object, resolve populates directly diff --git a/test/unit/actions/firestore.spec.js b/test/unit/actions/firestore.spec.js index 351c6dd6..8484a8a0 100644 --- a/test/unit/actions/firestore.spec.js +++ b/test/unit/actions/firestore.spec.js @@ -603,6 +603,22 @@ describe('firestoreActions', () => { }); }); }); + describe('populates', () => { + it('calls success callback if provided', async () => { + listenerConfig = { + collection: 'test', + doc: '1', + populates: [{ root: 'users', child: 'asdf' }], + }; + const instance = createFirestoreInstance( + fakeFirebase, + fakeConfig, + dispatchSpy, + ); + await instance.test.setListener(listenerConfig); + expect(dispatchSpy).to.have.been.calledOnce; + }); + }); }); describe('setListeners', () => { diff --git a/test/unit/reducers/orderedReducer.spec.js b/test/unit/reducers/orderedReducer.spec.js index e8976017..b31b431e 100644 --- a/test/unit/reducers/orderedReducer.spec.js +++ b/test/unit/reducers/orderedReducer.spec.js @@ -83,10 +83,27 @@ describe('orderedReducer', () => { }); describe('DOCUMENT_MODIFIED', () => { + it('preserves id on existing document - #252', () => { + const collection = 'test1'; + const doc = 'test2'; + const someDoc = { some: 'value' }; + const payload = { + data: someDoc, + }; + const meta = { collection, doc }; + action = { meta, payload, type: actionTypes.DOCUMENT_MODIFIED }; + const fakeState = { + [collection]: [{ id: doc, ...someDoc }, { id: 'id1' }, { id: 'id2' }], + }; + const result = orderedReducer(fakeState, action); + // ID + expect(result).to.have.nested.property(`${collection}.0.id`, doc); + }); + it('moves document within collection - #230', () => { const collection = 'test1'; const doc = 'test2'; - const someDoc = { id: doc, some: 'value' }; + const someDoc = { some: 'value' }; const otherDoc = { id: 'id1' }; const newIndex = 2; const oldIndex = 0; diff --git a/test/unit/utils/query.spec.js b/test/unit/utils/query.spec.js index 0ebac36f..87b0022d 100644 --- a/test/unit/utils/query.spec.js +++ b/test/unit/utils/query.spec.js @@ -6,6 +6,7 @@ import { firestoreRef, orderedFromSnap, dataByIdSnapshot, + getSnapshotByObject, } from 'utils/query'; import { actionTypes } from 'constants'; @@ -811,14 +812,14 @@ describe('query utils', () => { describe('dataByIdSnapshot', () => { it('sets data by id if valid', () => { const id = 'someId'; - const fakeData = 'some'; + const fakeData = { some: 'thing' }; result = dataByIdSnapshot({ id, data: () => fakeData, exists: true }); expect(result).to.have.property(id, fakeData); }); it('supports collection data', () => { const id = 'someId'; - const fakeData = 'some'; + const fakeData = { some: 'thing' }; result = dataByIdSnapshot({ forEach: func => func({ data: () => fakeData, id }), }); @@ -841,4 +842,42 @@ describe('query utils', () => { expect(result).to.have.property(id, null); }); }); + + describe('dataByIdSnapshot', () => { + it('retrieve snapshot with data from data state ', () => { + const id = 'someId'; + const fakeData = { some: 'thing' }; + const fakeSnap = { id, data: () => fakeData, exists: true }; + result = dataByIdSnapshot(fakeSnap); + expect(getSnapshotByObject(result)).to.equal(fakeSnap); + }); + + it('retrieve snapshot with data from data collection state ', () => { + const id = 'someId'; + const fakeData = { some: 'thing' }; + const fakeDocSnap = { id, data: () => fakeData, exists: true }; + const docArray = [fakeDocSnap]; + const fakeSnap = { forEach: docArray.forEach.bind(docArray) }; + result = dataByIdSnapshot(fakeSnap); + expect(getSnapshotByObject(result)).to.equal(fakeSnap); + }); + + it('retrieve snapshot with data from ordered state', () => { + const id = 'someId'; + const fakeData = { some: 'thing' }; + const fakeSnap = { id, data: () => fakeData, exists: true }; + result = orderedFromSnap(fakeSnap); + expect(getSnapshotByObject(result)).to.equal(fakeSnap); + }); + + it('retrieve snapshot with data from ordered collection state ', () => { + const id = 'someId'; + const fakeData = { some: 'thing' }; + const fakeDocSnap = { id, data: () => fakeData, exists: true }; + const docArray = [fakeDocSnap]; + const fakeSnap = { forEach: docArray.forEach.bind(docArray) }; + result = orderedFromSnap(fakeSnap); + expect(getSnapshotByObject(result)).to.equal(fakeSnap); + }); + }); });