@@ -660,7 +660,7 @@ describe('Autocomplete', function () {
660660
661661 it ( 'Should display no suggestion notice when no matching results' , function ( ) {
662662 var input = document . createElement ( 'input' ) ,
663- options = {
663+ options = {
664664 lookup : [ { value : 'Colombia' , data : 'Spain' } ] ,
665665 showNoSuggestionNotice : true ,
666666 noSuggestionNotice : 'Sorry, no matching results'
@@ -669,12 +669,38 @@ describe('Autocomplete', function () {
669669 suggestionsContainer = $ ( autocomplete . suggestionsContainer )
670670
671671 input . value = 'Jamaica' ;
672- autocomplete . onValueChange ( ) ;
672+ autocomplete . onValueChange ( ) ;
673673
674674 expect ( autocomplete . visible ) . toBe ( true ) ;
675675 expect ( autocomplete . selectedIndex ) . toBe ( - 1 )
676676 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 ) ;
678704 } ) ;
679705
680706} ) ;
0 commit comments