diff options
| author | Mark Otto <[email protected]> | 2012-06-02 22:14:12 -0700 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2012-06-02 22:14:12 -0700 |
| commit | 9a4ee790e1e58e321b604bb66380b2ce2f00faf6 (patch) | |
| tree | ac9099103a98153aeb5d69c674af5546c6aa926b /js/tests/unit | |
| parent | 9a3a297a478e1a27cce913b8d30170a6949b52f7 (diff) | |
| parent | 2d3a0babd242d7eebe09cf3f4daad38e2d7df6ee (diff) | |
| download | bootstrap-9a4ee790e1e58e321b604bb66380b2ce2f00faf6.tar.xz bootstrap-9a4ee790e1e58e321b604bb66380b2ce2f00faf6.zip | |
Merge branch '2.1.0-wip' of github.com:twitter/bootstrap into 2.1.0-wip
Conflicts:
docs/assets/js/bootstrap.min.js
Diffstat (limited to 'js/tests/unit')
| -rw-r--r-- | js/tests/unit/bootstrap-typeahead.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/js/tests/unit/bootstrap-typeahead.js b/js/tests/unit/bootstrap-typeahead.js index 4e2428d6a..25d4cafd8 100644 --- a/js/tests/unit/bootstrap-typeahead.js +++ b/js/tests/unit/bootstrap-typeahead.js @@ -52,6 +52,42 @@ $(function () { typeahead.$menu.remove() }) + test("should accept data source via synchronous function", function () { + var $input = $('<input />').typeahead({ + source: function () { + return ['aa', 'ab', 'ac'] + } + }) + , typeahead = $input.data('typeahead') + + $input.val('a') + typeahead.lookup() + + ok(typeahead.$menu.is(":visible"), 'typeahead is visible') + equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu') + equals(typeahead.$menu.find('.active').length, 1, 'one item is active') + + typeahead.$menu.remove() + }) + + test("should accept data source via asynchronous function", function () { + var $input = $('<input />').typeahead({ + source: function (query, process) { + process(['aa', 'ab', 'ac']) + } + }) + , typeahead = $input.data('typeahead') + + $input.val('a') + typeahead.lookup() + + ok(typeahead.$menu.is(":visible"), 'typeahead is visible') + equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu') + equals(typeahead.$menu.find('.active').length, 1, 'one item is active') + + typeahead.$menu.remove() + }) + test("should not explode when regex chars are entered", function () { var $input = $('<input />').typeahead({ source: ['aa', 'ab', 'ac', 'mdo*', 'fat+'] |
