You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 29, 2019. It is now read-only.
By default behaves as before. If specified, allows a custom function
to be defined to determine whether the keydown event should trigger
selection based on the `typeahead-should-select` attribute.
Closes#5671Closes#5794
it('should select a match when function returns true',function(){
477
+
$scope.shouldSelectFn=function(){
478
+
returntrue;
479
+
};
480
+
varelement=prepareInputEl('<div><input ng-model="result" typeahead-should-select="shouldSelectFn($event)" uib-typeahead="item for item in source | filter:$viewValue"></div>');
481
+
varinputEl=findInput(element);
482
+
483
+
changeInputValueTo(element,'b');
484
+
triggerKeyDown(element,13);
485
+
486
+
expect($scope.result).toEqual('bar');
487
+
expect(inputEl.val()).toEqual('bar');
488
+
expect(element).toBeClosed();
489
+
});
490
+
it('should not select a match when function returns false',function(){
491
+
$scope.shouldSelectFn=function(){
492
+
returnfalse;
493
+
};
494
+
varelement=prepareInputEl('<div><input ng-model="result" typeahead-should-select="shouldSelectFn($event)" uib-typeahead="item for item in source | filter:$viewValue"></div>');
495
+
varinputEl=findInput(element);
496
+
497
+
changeInputValueTo(element,'b');
498
+
triggerKeyDown(element,13);
499
+
500
+
// no change
501
+
expect($scope.result).toEqual('b');
502
+
expect(inputEl.val()).toEqual('b');
503
+
});
504
+
it('should pass key event into select trigger function',function(){
varelement=prepareInputEl('<div><input ng-model="result" typeahead-should-select="shouldSelectFn($event)" uib-typeahead="item for item in source | filter:$viewValue"></div>');
0 commit comments