test("should set input value to selected item", function () {
var $input = $('<input />').typeahead({
source: ['aa', 'ab', 'ac']
- })
+ }).appendTo('body')
, typeahead = $input.data('typeahead')
, changed = false
+ , focus = false
+ , blur = false
$input.val('a')
typeahead.lookup()
equals($input.val(), 'ac', 'input value was correctly set')
ok(!typeahead.$menu.is(':visible'), 'the menu was hidden')
ok(changed, 'a change event was fired')
+ ok(focus && !blur, 'focus is still set')
+ $input.remove()
typeahead.$menu.remove()
})