I'm looking to spyOn calls to the firebase database. I have a FireFunc file that wraps firebase calls. However, when I go to spyOn the check method, it returns the regular result. What's going on here?
var FireFunc = require("../js/services-fb-functions.js");
describe('Firebase Testing Suite', function() {
var firebase;
var testPath;
var testResult = {};
beforeAll(function() {
var firebaseFunctions = ['check']
firebase = jasmine.createSpyObj('firebase', firebaseFunctions)
firebase.check.and.callFake(function() {
return 2
});
});
describe('check', function() {
it('is working?', function() {
var x = FireFunc.zset()
expect(x).toBe(3); // THIS IS RETURNING 1... which means the spyOn doesn't work for me !
});
});
This is my code (js/services-fb-functions.js)
var firebase = {};
firebase.check = function() {
return 1;
}
module.exports = {
zset: function() {
return firebase.check();
}
}