I am very new to Jasmine unit test. I have pasted my code below. But not sure what i am doing wrong inside spec.Can you guys please guide me on the same.
var subscription = self.selectedEmpList.subscribe(function (selectedEmpList) {
if (selectedEmpList) {
dataService.getEmpsByEmpList(self.viewData.EmpId, selectedEmpList.id)
.done(loadEmpSpread);
}
Corresponding Spec what I am trying from whatever I got from googling.
var clickSelectedEmpList = null;
var empListSpy = null;
beforeEach(function () {
fil = new filter();
empListSpy = jasmine.createSpyObj("empListSpy", ["subscribe"]);
});
it('should be activatable', function () {
fil.activate(fixture.filterActivationData);
empListSpy.subscribe.and.callFake(function (selectedEmpList) {
clickSelectedEmpList = selectedEmpList;
});
clickSelectedEmpList();
});
And this is failed with error:-
TypeError: 'undefined' is not an object <evaluating 'empListSpy.subscribe.and.callFake'>