Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve create() with WriteResult #29

Merged
merged 67 commits into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
0aafc8f
fix(storage): handling the case when destination is not provided and …
Jan 18, 2019
9c12e14
fix(storage): new file should be created every time
Jan 18, 2019
2050c7f
fix(storage): do not recreate bucket every time
Jan 18, 2019
0c8659c
fix(storage): buffer should be sent as an array
Jan 18, 2019
78d29be
Add Timestamp
op Mar 1, 2019
c0aee17
Resolve create() with the write time
op Mar 1, 2019
e77ea3e
Move server clock handling out to utils
op Mar 2, 2019
4563e8f
Use serverClock in WriteResult
op Mar 2, 2019
da2895a
Add lodash isPlainObject dependency
op Apr 12, 2019
b8a2ebb
Return Timestamp for date related fields
op Apr 12, 2019
7796810
Fix infinite recursion on ref
op Apr 12, 2019
f4ac5ef
Expose Timestamp in SDK
op Apr 12, 2019
2ff0039
Restore some of the Server Timestamp logic
op Apr 16, 2019
532af4c
Fix orderBy for fields containing Date
op Apr 16, 2019
f614189
Add test for orderBy with Date
op Apr 16, 2019
41174bc
Use same server time in WriteResult as in docs
op Apr 26, 2019
6fe4e0b
Merge branch 'master' into create-write-result
dmurvihill Nov 19, 2019
4c0e7de
Merge branch 'master' into thomasrup-master
dmurvihill Nov 19, 2019
4b187d7
call onAuthStateChanged callback immediately
zeevl Nov 20, 2019
731888e
Merge branch 'call-onautstatechanged-immediately' into v3.0
dmurvihill Nov 21, 2019
a2d7ec1
removed .vscode
zeevl Nov 22, 2019
b9135cf
removed extra space
zeevl Nov 22, 2019
39cb1d0
Merge branch 'thomasrup-master' into v3.0
dmurvihill Nov 25, 2019
bf6393f
Add changelog
dmurvihill Nov 25, 2019
21e07f2
Update gulp shell plugin
dmurvihill Dec 11, 2019
cf32575
Merge branch 'master' into v3.0
dmurvihill Dec 11, 2019
d1bdb43
Merge pull request #39 from zeevl/call-onautstatechanged-immediately
dmurvihill Dec 11, 2019
5119ca4
Factor auth state changed test setup
dmurvihill Dec 12, 2019
b9f1fd3
Add tests for Users preserving auth reference equality
dmurvihill Dec 16, 2019
568e8e9
Refactor User.getIdToken
dmurvihill Dec 16, 2019
34bdeef
Add support for firebase messaging
raman-nbg Dec 16, 2019
7c1c36a
Add docs how to use firebase messaging mock
raman-nbg Dec 16, 2019
48313d7
Add callbacks to messagint for assertions
raman-nbg Dec 17, 2019
2ce2dc1
fix: add boolean as acceptable query priority type
Redmega Dec 17, 2019
1d38545
Merge branch 'master' into fix-boolean-query-params
dmurvihill Dec 17, 2019
e1a74ae
Add changelog entry
dmurvihill Dec 17, 2019
e8690c8
Merge pull request #45 from dmurvihill/fix-boolean-query-params
dmurvihill Dec 17, 2019
cf2d344
fix: add real test
Redmega Dec 17, 2019
f0db35f
Merge branch 'master' into onIdTokenChanged
dmurvihill Dec 18, 2019
c6d5af7
fix: add bool to priorityComparator, add tests
Redmega Dec 18, 2019
6429747
fix: add priority metadata to bool ordered fields
Redmega Dec 18, 2019
eef102b
Rename MockMessaging.nextResult() to respondNext()
raman-nbg Dec 18, 2019
805c7f4
Add docs for MockMessaging
raman-nbg Dec 18, 2019
f99c9fb
Fix docs for Messaging
raman-nbg Dec 18, 2019
0ee4189
Add API Reference for MockMessaging
raman-nbg Dec 18, 2019
fe1850e
Add Changelog for Messaging support
raman-nbg Dec 18, 2019
774503e
Minor changelog update
dmurvihill Dec 19, 2019
a1957f1
Merge pull request #46 from Redmega/master
dmurvihill Dec 19, 2019
d8e73dd
Clean up auth and user tests
dmurvihill Dec 19, 2019
6469bd9
Add a couple of extra auth/user tests
dmurvihill Dec 19, 2019
b0e670d
Implement onIdTokenChanged and update onAuthStateChanged
dmurvihill Dec 19, 2019
90f35ab
Remove a few warnings from auth
dmurvihill Dec 19, 2019
e92a4ba
Merge branch 'master' into onIdTokenChanged
dmurvihill Dec 19, 2019
23a6289
Quick changelog fix
dmurvihill Dec 19, 2019
846d890
Remove two unused imports
dmurvihill Dec 19, 2019
57b4a22
Fix unit test
raman-nbg Dec 21, 2019
f687e89
Fix typo in API docs
raman-nbg Dec 21, 2019
a6e627e
Change NPM URLs to new repo
dmurvihill Dec 30, 2019
744d6b0
Merge pull request #49 from dmurvihill/fix-repo-url
dmurvihill Dec 30, 2019
891551e
Make docs match tests
dmurvihill Jan 3, 2020
ba6acb0
Merge pull request #43 from raman-nbg/messaging
dmurvihill Jan 3, 2020
496b37f
Merge pull request #48 from dmurvihill/remove-warnings
dmurvihill Jan 3, 2020
3175bb8
Merge branch 'onIdTokenChanged'
dmurvihill Jan 3, 2020
d65329d
Merge remote-tracking branch 'origin/master' into timestamp
dmurvihill Jan 6, 2020
467ecc0
Merge pull request #27 from dmurvihill/timestamp
dmurvihill Jan 6, 2020
ab258e1
Merge branch 'master' of github.com:dmurvihill/firebase-mock
dmurvihill Jan 8, 2020
d883b80
Merge branch 'create-write-result' of github.com:dmurvihill/firebase-…
dmurvihill Jan 8, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 42 additions & 5 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ Only `MockFirebase` methods are included here. For details on normal Firebase AP
- [Server Timestamps](#server-timestamps)
- [`setClock(fn)`](#firebasesetclockfn---undefined)
- [`restoreClock()`](#firebasesetclockfn---undefined)
- [Messaging](#messaging)
- [`respondNext(methodName, result)`](#respondnextmethodname-result---undefined)
- [`failNext(methodName, err)`](#failnextmethodname-err---undefined)
- [`on(methodName, callback)`](#onmethodname-callback---undefined)

## Core

Expand Down Expand Up @@ -175,8 +179,9 @@ Authentication methods for simulating changes to the auth state of a Firebase re
Changes the active authentication credentials to the `authData` object.
Before changing the authentication state, `changeAuthState` checks the
`user` object against the current authentication data.
`onAuthStateChanged` listeners will only be triggered if the data is not
deeply equal.
`onIdTokenChanged` listeners will be triggered if the data is not
deeply equal. `onAuthStateChanged` listeners will be triggered if the
data is deeply equal but with different ID token validity.

`user` should be a `MockUser` object or an object with the same fields
as `MockUser`. To simulate no user being authenticated, pass `null` for
Expand Down Expand Up @@ -225,9 +230,13 @@ Finds a user previously created with [`createUser`](https://www.firebase.com/doc
##### `updateUser(user)` -> `Promise<MockUser>`

Replace the existing user with a new one, by matching uid. Throws an
error if no user exists whose uid matches the given user's uid. Resolves
with the updated user when complete. This operation is queued until the
next flush.
error if no user exists whose uid matches the given user's uid.
Appropriate `onAuthStateChanged` and `onIdTokenChanged` listeners will
be triggered if the new user has the same `uid` as the current
authenticated user.

Resolves with the updated user when complete. This operation is queued
until the next flush.

## Server Timestamps

Expand All @@ -242,3 +251,31 @@ Instead of using `Date.now()`, MockFirebase will call the `fn` you provide to ge
##### `Firebase.restoreClock()` -> `undefined`

After calling `Firebase.setClock`, calling `Firebase.restoreClock` will restore the default timestamp behavior.

## Messaging

API reference of `MockMessaging`.

##### `respondNext(methodName, result)` -> `undefined`

When `methodName` is next invoked, the `Promise` (that is returned from the `methodName`) will be resolved with the specified `result`. This is useful for testing specific results of firebase messaging (e. g. partial success of sending messaging). The result will be triggered with the next `flush`.

If no result is specified, `methodName` will resolve a default response.

`result` must not be undefined.

<hr>

##### `failNext(methodName, err)` -> `undefined`

When `methodName` is next invoked, the `Promise` will be rejected with the specified `err`. This is useful for simulating validation or any other errors. The error will be triggered with the next `flush`.

`err` must be a proper `Error` object and not a string or any other primitive.

<hr>

##### `on(methodName, callback)` -> `undefined`

When `methodName` is next invoked, the `callback` will be triggered. The callback gets an array as argument. The array contains all arguments, that were passed on invoking `methodName`. This is useful to assert the input arguments of `methodName`.

See [docs.js](/test/unit/docs.js) for an example.
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Changelog
- Mock `auth.Auth.onIdTokenChanged()` method, matching the previous
behavior of `onAuthStateChanged()` (see below)
- Support for Firebase Messaging (Admin API)

### Changed
- (Breaking) Consistent with Firebase SDK [version 4.0.0](https://firebase.google.com/support/release-notes/js#version_500_-_may_8_2018) and later,
and later, `onAuthStateChanged` no longer issues an event when a new
ID token is issued for the same user. The `onIdTokenChanged` method is
now mocked, keeping the previous behavior.
- `MockStorageFile.download()` now allows omitting the destination arg;
in that case, it simply resolves the `Promise` with the file contents
and does not write it anywhere else.

### Fixed
- `onAuthStateChanged` now correctly calls its callback immediately with
the current auth state.
- `MockStorage.bucket()` and `MockStorageBucket.file()` now return the
existing artifact if one exists, rather than overwriting it with a new
one.
- `DataSnapshot.child` now correctly splits child paths by '/'
characters
- Boolean values are now allowed in RTDB priority fields and as
arguments to `Query.startAt`, `Query.endAt`, and `Query.equalTo`.


[Unreleased]: https://github.com/dmurvihill/firebase-mock/compare/v2.2.10...HEAD
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Firebase Mock supports the client-side [JavaScript API](https://firebase.google.
* Authentication
* [Basic](tutorials/admin/authentication.md)
* [JWT Tokens](tutorials/admin/tokens.md)
* [Messaging](tutorials/admin/messaging.md)
* [Realtime Database](tutorials/admin/rtdb.md)
* [Firestore](tutorials/admin/firestore.md)
* [Storage](tutorials/admin/storage.md)
Expand Down
Loading