假设我们有一个使用service
的{{1}}函数。我们filter
如何spyOn
确保调用它?
答案 0 :(得分:0)
尝试以下代码:
describe('myServiceTest', function() {
var myServiceWhichCallsMyFilter;
var myFilterSpy = jasmine.createSpy('');
beforeEach(module('myApp'));
beforeEach(module(function ($provide) {
$provide.value('myFilterFilter', myFilterSpy );
}));
beforeEach(inject(function (_myServiceWhichCallsMyFilter_) {
myServiceWhichCallsMyFilter = _myServiceWhichCallsMyFilter_;
}));
});