@@ -660,7 +660,7 @@ describe('Autocomplete', function () {
660
660
661
661
it ( 'Should display no suggestion notice when no matching results' , function ( ) {
662
662
var input = document . createElement ( 'input' ) ,
663
- options = {
663
+ options = {
664
664
lookup : [ { value : 'Colombia' , data : 'Spain' } ] ,
665
665
showNoSuggestionNotice : true ,
666
666
noSuggestionNotice : 'Sorry, no matching results'
@@ -669,12 +669,38 @@ describe('Autocomplete', function () {
669
669
suggestionsContainer = $ ( autocomplete . suggestionsContainer )
670
670
671
671
input . value = 'Jamaica' ;
672
- autocomplete . onValueChange ( ) ;
672
+ autocomplete . onValueChange ( ) ;
673
673
674
674
expect ( autocomplete . visible ) . toBe ( true ) ;
675
675
expect ( autocomplete . selectedIndex ) . toBe ( - 1 )
676
676
expect ( suggestionsContainer . find ( '.autocomplete-no-suggestion' ) . length ) . toBe ( 1 )
677
- expect ( suggestionsContainer . find ( '.autocomplete-no-suggestion' ) . text ( ) ) . toBe ( 'Sorry, no matching results' )
677
+ expect ( suggestionsContainer . find ( '.autocomplete-no-suggestion' ) . text ( ) ) . toBe ( 'Sorry, no matching results' )
678
+ } ) ;
679
+
680
+ it ( 'Should call onHide and pass container jQuery object' , function ( ) {
681
+ var element = document . createElement ( 'input' ) ,
682
+ input = $ ( element ) ,
683
+ instance ,
684
+ elementCount ,
685
+ context ;
686
+
687
+ input . autocomplete ( {
688
+ lookup : [ { value : 'Jamaica' , data : 'B' } ] ,
689
+ onHide : function ( container ) {
690
+ context = this ;
691
+ elementCount = container . length ;
692
+ }
693
+ } ) ;
694
+
695
+ input . val ( 'Jam' ) ;
696
+ instance = input . autocomplete ( ) ;
697
+ instance . onValueChange ( ) ;
698
+
699
+ input . val ( 'Colombia' ) ;
700
+ instance . onValueChange ( ) ;
701
+
702
+ expect ( context ) . toBe ( element ) ;
703
+ expect ( elementCount ) . toBe ( 1 ) ;
678
704
} ) ;
679
705
680
706
} ) ;
0 commit comments