This repository was archived by the owner on Oct 2, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change 44/.idea
55/.tmp
66.DS_Store
7+ npm-debug.log
78* ~
Original file line number Diff line number Diff line change @@ -297,15 +297,16 @@ uis.controller('uiSelectCtrl',
297297 $timeout . cancel ( _refreshDelayPromise ) ;
298298 }
299299 _refreshDelayPromise = $timeout ( function ( ) {
300- if ( $scope . $select . search . length >= $scope . $select . minimumInputLength ) {
300+ if ( $scope . $select . search . length >= $scope . $select . minimumInputLength ) {
301301 var refreshPromise = $scope . $eval ( refreshAttr ) ;
302302 if ( refreshPromise && angular . isFunction ( refreshPromise . then ) && ! ctrl . refreshing ) {
303303 ctrl . refreshing = true ;
304304 refreshPromise . finally ( function ( ) {
305305 ctrl . refreshing = false ;
306306 } ) ;
307+ }
307308 }
308- } } , ctrl . refreshDelay ) ;
309+ } , ctrl . refreshDelay ) ;
309310 }
310311 } ;
311312
Original file line number Diff line number Diff line change @@ -1643,6 +1643,46 @@ describe('ui-select tests', function() {
16431643 expect ( scope . fetchFromServer ) . toHaveBeenCalledWith ( 'red' ) ;
16441644 } ) ;
16451645
1646+
1647+ it ( 'should call refresh function respecting minimum input length option with given refresh-delay' , function ( ) {
1648+
1649+ var el = compileTemplate (
1650+ '<ui-select ng-model="selection.selected"> \
1651+ <ui-select-match> \
1652+ </ui-select-match> \
1653+ <ui-select-choices repeat="person in people | filter: $select.search" \
1654+ refresh="fetchFromServer($select.search)" refresh-delay="1" minimum-input-length="3"> \
1655+ <div ng-bind-html="person.name | highlight: $select.search"></div> \
1656+ <div ng-if="person.name==\'Wladimir\'"> \
1657+ <span class="only-once">I should appear only once</span>\
1658+ </div> \
1659+ </ui-select-choices> \
1660+ </ui-select>'
1661+ ) ;
1662+
1663+ scope . fetchFromServer = function ( ) { } ;
1664+
1665+ spyOn ( scope , 'fetchFromServer' ) ;
1666+
1667+ el . scope ( ) . $select . search = 'redd' ;
1668+ scope . $digest ( ) ;
1669+ $timeout . flush ( ) ;
1670+ expect ( scope . fetchFromServer ) . toHaveBeenCalledWith ( 'redd' ) ;
1671+
1672+
1673+ el . scope ( ) . $select . search = 'red' ;
1674+ scope . $digest ( ) ;
1675+ el . scope ( ) . $select . search = 're' ;
1676+ scope . $digest ( ) ;
1677+ el . scope ( ) . $select . search = 'r' ;
1678+ scope . $digest ( ) ;
1679+ $timeout . flush ( ) ;
1680+ expect ( scope . fetchFromServer ) . not . toHaveBeenCalledWith ( 'r' ) ;
1681+
1682+
1683+ } ) ;
1684+
1685+
16461686 it ( 'should format view value correctly when using single property binding and refresh function' , function ( ) {
16471687
16481688 var el = compileTemplate (
You can’t perform that action at this time.
0 commit comments