katowulf / mockfirebase

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

Fixed a bug related to child_add due to changeMap using in, out and expe... #75

Closed CurtisHumphrey closed 9 years ago

CurtisHumphrey commented 9 years ago

...cting to use added, removed

bendrucker commented 9 years ago

Can you add a failing test here?

bendrucker commented 9 years ago

Or even just describe something you were trying to do that was broken and I'll commit the test

CurtisHumphrey commented 9 years ago

I found it when I subscribing to a 'child add' event instead of a once 'value' event. When I pushed a new value later it did not update because handleRefEvent function expect change map to have keys added and removed and the function originally returned in and out. Do you still need a test or do you see it from inspection?

bendrucker commented 9 years ago

Would be helpful to see a test so I can be sure I'm fixing it

CurtisHumphrey commented 9 years ago

I'm working on one but at this point I have not be able to reproduce it outside of my code base. I could create a simple test to check that changeMap returns an object with keys "added" and "removed" if you want.

bendrucker commented 9 years ago

Ideally I'd like to see something that only calls the public API

CurtisHumphrey commented 9 years ago

By inspection you can see that "_.each(map.added, function (addKey) { self.fakeEvent('childadded', newSnap.child(addKey)); }); .each(map.removed, function (remKey) { self.fakeEvent('child_removed', oldSnap.child(remKey)); });" will never work without changeMap returning the correct object structure.

CurtisHumphrey commented 9 years ago

Got it. Post coming soon.

CurtisHumphrey commented 9 years ago

So it happen with some interplay of the startAt (not related to queries 2.0). Test uses only the public APIs.

CurtisHumphrey commented 9 years ago

Do you need anything else to incorporate this change?

bendrucker commented 9 years ago

Thanks for the reminder

CurtisHumphrey commented 9 years ago

Thanks!

bendrucker commented 9 years ago

Sure — thank you!