2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-25 14:17:45 +00:00

added test case for onHide callback

This commit is contained in:
Steffen Dietz 2014-08-28 12:15:17 +02:00
parent 5d5513f0f2
commit fdae40056f

View File

@ -677,4 +677,30 @@ describe('Autocomplete', function () {
expect(suggestionsContainer.find('.autocomplete-no-suggestion').text()).toBe('Sorry, no matching results')
});
it('Should call onHide and pass container jQuery object', function () {
var element = document.createElement('input'),
input = $(element),
instance,
elementCount,
context;
input.autocomplete({
lookup: [{ value: 'Jamaica', data: 'B' }],
onHide: function (container) {
context = this;
elementCount = container.length;
}
});
input.val('Jam');
instance = input.autocomplete();
instance.onValueChange();
input.val('Colombia');
instance.onValueChange();
expect(context).toBe(element);
expect(elementCount).toBe(1);
});
});