katowulf / mockfirebase

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

Support onDisconnect() #62

Open allannaranjo opened 9 years ago

allannaranjo commented 9 years ago

Looking at firebase.js and mockfirebase.js I see that the onDisconnect method is not implemented. This is causing our test to fail.

See firebase onDisconnect:

E.prototype.ia = function() {
    return new $(this.m, this.path, this.name())
};
E.prototype.onDisconnect = E.prototype.ia;
bendrucker commented 9 years ago

That's correct. Right now you can just mutate MockFirebase.prototype so that ref.onDisconnect is an identity/noop. Otherwise online/offline support is on my list.

katowulf commented 9 years ago

So, for example, my test units have some items like this (which I use to mock the new 2.0 methods):

var _ = require('lodash');

// _.noop is essentially just an empty function

_.extend(MockFirebase.prototype, {
    onDisconnect: _.noop,
    authWithOAuthPassword: _.noop,
    limitToFirst: jasmine.createSpy('limitToFirst'),
    // and so on...
});