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

后端 未结 3 1574
耶瑟儿~
耶瑟儿~ 2021-02-20 03:57

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)

提交回复
热议问题