This repository was archived by the owner on Oct 2, 2019. It is now read-only.
File tree 3 files changed +44
-2
lines changed
3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change 4
4
/.idea
5
5
/.tmp
6
6
.DS_Store
7
+ npm-debug.log
7
8
* ~
Original file line number Diff line number Diff line change @@ -297,15 +297,16 @@ uis.controller('uiSelectCtrl',
297
297
$timeout . cancel ( _refreshDelayPromise ) ;
298
298
}
299
299
_refreshDelayPromise = $timeout ( function ( ) {
300
- if ( $scope . $select . search . length >= $scope . $select . minimumInputLength ) {
300
+ if ( $scope . $select . search . length >= $scope . $select . minimumInputLength ) {
301
301
var refreshPromise = $scope . $eval ( refreshAttr ) ;
302
302
if ( refreshPromise && angular . isFunction ( refreshPromise . then ) && ! ctrl . refreshing ) {
303
303
ctrl . refreshing = true ;
304
304
refreshPromise . finally ( function ( ) {
305
305
ctrl . refreshing = false ;
306
306
} ) ;
307
+ }
307
308
}
308
- } } , ctrl . refreshDelay ) ;
309
+ } , ctrl . refreshDelay ) ;
309
310
}
310
311
} ;
311
312
Original file line number Diff line number Diff line change @@ -1643,6 +1643,46 @@ describe('ui-select tests', function() {
1643
1643
expect ( scope . fetchFromServer ) . toHaveBeenCalledWith ( 'red' ) ;
1644
1644
} ) ;
1645
1645
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
+
1646
1686
it ( 'should format view value correctly when using single property binding and refresh function' , function ( ) {
1647
1687
1648
1688
var el = compileTemplate (
You can’t perform that action at this time.
0 commit comments