mockfirebase icon indicating copy to clipboard operation
mockfirebase copied to clipboard

Support onDisconnect()

Open allannaranjo opened this issue 10 years ago • 2 comments

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;

allannaranjo avatar Jan 22 '15 18:01 allannaranjo

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.

bendrucker avatar Jan 22 '15 20:01 bendrucker

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...
});

katowulf avatar Jan 25 '15 17:01 katowulf