JasmineJS / AngularJs:如何窥探$ filter

时间:2016-05-20 04:15:53

标签: angularjs unit-testing jasmine angularjs-filter

假设我们有一个使用service的{​​{1}}函数。我们filter如何spyOn确保调用它?

1 个答案:

答案 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_;
    }));

});