diff options
author | fat <jacobthornton@gmail.com> | 2012-12-08 04:16:48 +0400 |
---|---|---|
committer | fat <jacobthornton@gmail.com> | 2012-12-08 04:16:48 +0400 |
commit | 820a3b27b6cfd320584be5a8e1652c7dff9771e4 (patch) | |
tree | 989995e4b9dd43f5492254a3e4b439ecc13acffd /js/tests/unit/bootstrap-typeahead.js | |
parent | 1747caf19d59cad7fdc90ae56a00e0e2849f95f4 (diff) |
get tests passing for typeahead :P
Diffstat (limited to 'js/tests/unit/bootstrap-typeahead.js')
-rw-r--r-- | js/tests/unit/bootstrap-typeahead.js | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/js/tests/unit/bootstrap-typeahead.js b/js/tests/unit/bootstrap-typeahead.js index 0cf26b3153..4bdbce9709 100644 --- a/js/tests/unit/bootstrap-typeahead.js +++ b/js/tests/unit/bootstrap-typeahead.js @@ -38,7 +38,9 @@ $(function () { }) test("should show menu when query entered", function () { - var $input = $('<input />').typeahead({ + var $input = $('<input />') + .appendTo('body') + .typeahead({ source: ['aa', 'ab', 'ac'] }) , typeahead = $input.data('typeahead') @@ -50,6 +52,7 @@ $(function () { equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu') equals(typeahead.$menu.find('.active').length, 1, 'one item is active') + $input.remove() typeahead.$menu.remove() }) @@ -58,7 +61,7 @@ $(function () { source: function () { return ['aa', 'ab', 'ac'] } - }) + }).appendTo('body') , typeahead = $input.data('typeahead') $input.val('a') @@ -68,6 +71,7 @@ $(function () { equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu') equals(typeahead.$menu.find('.active').length, 1, 'one item is active') + $input.remove() typeahead.$menu.remove() }) @@ -76,7 +80,7 @@ $(function () { source: function (query, process) { process(['aa', 'ab', 'ac']) } - }) + }).appendTo('body') , typeahead = $input.data('typeahead') $input.val('a') @@ -86,13 +90,14 @@ $(function () { equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu') equals(typeahead.$menu.find('.active').length, 1, 'one item is active') + $input.remove() typeahead.$menu.remove() }) test("should not explode when regex chars are entered", function () { var $input = $('<input />').typeahead({ source: ['aa', 'ab', 'ac', 'mdo*', 'fat+'] - }) + }).appendTo('body') , typeahead = $input.data('typeahead') $input.val('+') @@ -102,6 +107,7 @@ $(function () { equals(typeahead.$menu.find('li').length, 1, 'has 1 item in menu') equals(typeahead.$menu.find('.active').length, 1, 'one item is active') + $input.remove() typeahead.$menu.remove() }) @@ -109,7 +115,7 @@ $(function () { stop() var $input = $('<input />').typeahead({ source: ['aa', 'ab', 'ac'] - }) + }).appendTo('body') , typeahead = $input.data('typeahead') $input.val('a') @@ -126,13 +132,14 @@ $(function () { start() }, 200) + $input.remove() typeahead.$menu.remove() }) test("should set next item when down arrow is pressed", function () { var $input = $('<input />').typeahead({ source: ['aa', 'ab', 'ac'] - }) + }).appendTo('body') , typeahead = $input.data('typeahead') $input.val('a') @@ -159,7 +166,6 @@ $(function () { ok(typeahead.$menu.find('li').first().next().hasClass('active'), "second item is active") - $input.trigger({ type: 'keydown' , keyCode: 38 @@ -175,6 +181,7 @@ $(function () { ok(typeahead.$menu.find('li').first().hasClass('active'), "first item is active") + $input.remove() typeahead.$menu.remove() }) @@ -182,7 +189,7 @@ $(function () { 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 @@ -197,6 +204,7 @@ $(function () { ok(!typeahead.$menu.is(':visible'), 'the menu was hidden') ok(changed, 'a change event was fired') + $input.remove() typeahead.$menu.remove() }) @@ -204,7 +212,7 @@ $(function () { var $input = $('<input />').typeahead({ source: ['aaaa', 'aaab', 'aaac'], minLength: 3 - }) + }).appendTo('body') , typeahead = $input.data('typeahead') $input.val('aa') @@ -217,6 +225,7 @@ $(function () { equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu') + $input.remove() typeahead.$menu.remove() }) }) |