How to test input using debg ng-model-option?

I have an input with ng-model-options="{debounce:250}"

and let's say that I have an ng change on an element and a spy on this function. Now, if I do a simple input test, for example:

it('test', function(){
  input.val('hello');

  expect(ngChangeSpy).toHaveBeenCalledWith('hello');
})

obviously this does not work. I saw that you can wait for promises to be resolved and such, but here I just want to wait 250 milliseconds for the model to change. Is there any way to achieve this?

+4
source share
1 answer

You can use $ timeout.flush () https://docs.angularjs.org/api/ngMock/service/ $ timeout to clear pending functions if you don't want to test 250 ms.

0

Source: https://habr.com/ru/post/1626975/


All Articles