I have my script (playground.efs) which I want to test. However, it uses the eSignal API, so I have to spy any of those functions.
I'm having trouble setting up spyOn
, I don't know what to object to spy on should be. With testing testEfsCode()
, a spy for getCurrentBarIndex()
needs to be created. Since getCurrentBarIndex()
isn't apart of any object how can I stub it?
The error I'm getting with my current code is:
Error: <spyOn> : getCurrentBarIndex() method does not exist Usage: spyOn(<object>, <methodName>)
TestSpec.js
var util = require('../../../Interactive Data/Formulas/My Formulas/playground.efs');
describe("Utils", function() {
it("should return true", function() {
var spy = spyOn(util.testEfsCode, 'getCurrentBarIndex').and.callThrough();
expect(util.testEfsCode()).toBe(true);
});
});
playground.efs (Script To Test)
function testEfsCode(){
getCurrentBarIndex();
return true;
}
// Check For EFS
if ( typeof module !== 'undefined' && module.hasOwnProperty('exports') )
{
module.exports = {
testEfsCode: testEfsCode
}
}
getCurrentBarIndex()
is a function supplied by eSignal, so I don't have the code for it. The function only runs when the script is loaded into eSignal.