--Source Code
function myFunction() {
if (flag) {
function_1();
}
else {
function_2();
}
};
--Jasmine Spec
/// <reference path="scripts/myFunctions.js" />
describe('Test Suite 1:', function() {
var functions;
beforeEach(function () {
functions = {
myFunction: myFunction,
function_1: function_1
}
spyOn(functions, 'myFunction').and.callThrough();
spyOn(functions, 'function_1');
}
it('should call function_1 is flag is true', function () {
//When: I call myFunction()
functions.myFunction();
//Then: I verify function_1 called once
expect(functions.function_1.calls.count()).toEqual(1);
});
});
In above code flag is a bool variable, when i run test case it's not able to find reference to that variable. How can i make it work ?