I have an input with ng-model-options="{debounce:250}"
and say I have a ng-change on the element and spy on that function. now if I do a simple test of the input like:
it('test', function(){
input.val('hello');
expect(ngChangeSpy).toHaveBeenCalledWith('hello');
})
obviously this doesn't work. I've seen you can wait for promises to resolve and such, but here I just want to wait 250 milliseconds in order for the model to change. Is there a way to achieve this?
You can use $timeout.flush() https://docs.angularjs.org/api/ngMock/service/$timeout to flush your deferred functions if you don't want to test the 250ms delay.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With