How to force an input change trigger with ng-model-options debounce in AngularJS?
I am testing my library. The problem is I have debounce on the textbox to avoid frequent updates.
how
<input ... ng-model-options="{debounce: {'default': 500, 'blur': 0} }"
But I cannot turn it off in tests, even I tried to call blur
it("""test input set with debounce""", function(){
scope.obj = {
name: 'John'
}
el = compileTemplate("<span><input ng-model=\"obj.name\" ng-model-options=\"{debounce: {'default': 500, 'blur': 0} }\"></input></span>")
scope.$digest()
input = el.find('input');
expect(input.val()).toEqual('John');
angular.element(input).val('Max').trigger('change').trigger('blur')
scope.$apply()
expect(scope.obj.name).toEqual('Max');
})
This will fail because I need to add $ timeout. So 10 tests = 5 seconds delay, which is inappropriate.
How can I make the trigger change
avoid debounce or trigger blur
?
+3
source to share
2 answers