Testing a debounced function in AngularJS with Jasmine never calls the function

后端 未结 3 1662
野趣味
野趣味 2021-02-20 04:12

I have a method in a service that uses underscore\'s debounce.

Inside that method is a call to a method on a different service. I\'m trying to test that the different s

3条回答
  •  遇见更好的自我
    2021-02-20 04:33

    My debounced function took arguments so I mocked _.debounce like this

    spyOn(_, 'debounce').and.callFake(function(cb) {return cb});

    (slight modification on @Wawy's answer)

提交回复
热议问题