katowulf / mockfirebase

Firebase mock library for writing unit tests (experimental)
157 stars 40 forks source link

Throw immediately for validation errors #81

Closed bendrucker closed 9 years ago

bendrucker commented 9 years ago

This is a bug but may affect existing implementations. Pretty sure it only affects auth but there may be some other problem areas I'm not thinking of.

Validation errors that are determined on the client should be throw immediately and not wait for a flush. This is consistent with the real firebase.js, where validation errors are thrown and server errors are passed to a callback.

Since this is an issue of parity with the real Firebase lib, the fix will go out as a patch and not a minor version bump.

katowulf commented 9 years ago

Hey @bendrucker, great work here. Did you check whether those errors are thrown sync v. async? I'm fairly sure they are sync, but that's unusual for Firebase so it would be good to be consistent.

bendrucker commented 9 years ago

Yeah I checked that they're sync. For example:

https://github.com/firebase/firebase-bower/blob/75f63a2350f340772188729d6950844c9f3296fb/firebase-debug.js#L12426

Which ultimates throws or is a noop:

https://github.com/firebase/firebase-bower/blob/75f63a2350f340772188729d6950844c9f3296fb/firebase-debug.js#L3199-L3212