it('should call getCompany on the people service when getCompany is called',
function () {
spyOn(peopleService, 'requestPeople').andCallThrough();
scope.getCompany();
deferred.resolve();
scope.$root.$digest();
expect(peopleService.requestPeople).toHaveBeenCalled();
});
it('should populate the peopleList when getCompany is called',
function () {
scope.getCompany();
deferred.resolve();
scope.$root.$digest();
expect(scope.peopleList).not.toBe([]);
});
我有一段代码嘲笑服务,但我收到了错误 如上所述。任何一个人都面临同样的问题?有任何修正吗?
答案 0 :(得分:4)
检查您正在使用的Jasmine版本。
在Jasmine 1.3中使用 .andCallThrough()
,你应该在Jasmine 2.x中使用.and.callThrough()