diff options
| author | Mark Otto <[email protected]> | 2012-07-23 23:01:38 -0700 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2012-07-23 23:01:38 -0700 |
| commit | f085dbadd18208386649717f4f1bcba62d6119de (patch) | |
| tree | e8aa445377a1877816ea4636f015117c06096404 /js/tests | |
| parent | 0dda2c4659c6e0407b5b9fda6618ab5c8c12a897 (diff) | |
| parent | 614d52bd7f86591a0b0ab09e1c16ee888610d8a3 (diff) | |
| download | bootstrap-f085dbadd18208386649717f4f1bcba62d6119de.tar.xz bootstrap-f085dbadd18208386649717f4f1bcba62d6119de.zip | |
Merge branch '2.1.0-wip' of github.com:twitter/bootstrap into 2.1.0-wip
Conflicts:
docs/assets/css/docs.css
docs/base-css.html
docs/components.html
docs/customize.html
docs/getting-started.html
docs/javascript.html
docs/scaffolding.html
docs/templates/pages/base-css.mustache
docs/templates/pages/components.mustache
docs/templates/pages/customize.mustache
docs/templates/pages/getting-started.mustache
docs/templates/pages/javascript.mustache
docs/templates/pages/scaffolding.mustache
Diffstat (limited to 'js/tests')
| -rw-r--r-- | js/tests/index.html | 2 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-affix.js | 19 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-popover.js | 8 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-tooltip.js | 8 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-typeahead.js | 20 |
5 files changed, 53 insertions, 4 deletions
diff --git a/js/tests/index.html b/js/tests/index.html index 2f8f71b12..976ca1687 100644 --- a/js/tests/index.html +++ b/js/tests/index.html @@ -27,6 +27,7 @@ <script src="../../js/bootstrap-tooltip.js"></script> <script src="../../js/bootstrap-popover.js"></script> <script src="../../js/bootstrap-typeahead.js"></script> + <script src="../../js/bootstrap-affix.js"></script> <!-- unit tests --> <script src="unit/bootstrap-transition.js"></script> @@ -41,6 +42,7 @@ <script src="unit/bootstrap-tooltip.js"></script> <script src="unit/bootstrap-popover.js"></script> <script src="unit/bootstrap-typeahead.js"></script> + <script src="unit/bootstrap-affix.js"></script> </head> <body> <div> diff --git a/js/tests/unit/bootstrap-affix.js b/js/tests/unit/bootstrap-affix.js new file mode 100644 index 000000000..bc25df991 --- /dev/null +++ b/js/tests/unit/bootstrap-affix.js @@ -0,0 +1,19 @@ +$(function () { + + module("bootstrap-affix") + + test("should be defined on jquery object", function () { + ok($(document.body).affix, 'affix method is defined') + }) + + test("should return element", function () { + ok($(document.body).affix()[0] == document.body, 'document.body returned') + }) + + test("should exit early if element is not visible", function () { + var $affix = $('<div style="display: none"></div>').affix() + $affix.data('affix').checkPosition() + ok(!$affix.hasClass('affix'), 'affix class was not added') + }) + +})
\ No newline at end of file diff --git a/js/tests/unit/bootstrap-popover.js b/js/tests/unit/bootstrap-popover.js index 6d5d9f7a1..daffe215c 100644 --- a/js/tests/unit/bootstrap-popover.js +++ b/js/tests/unit/bootstrap-popover.js @@ -92,12 +92,16 @@ $(function () { }) test("should destroy popover", function () { - var popover = $('<div/>').popover() + var popover = $('<div/>').popover().on('click.foo', function(){}) ok(popover.data('popover'), 'popover has data') ok(popover.data('events').mouseover && popover.data('events').mouseout, 'popover has hover event') + ok(popover.data('events').click[0].namespace == 'foo', 'popover has extra click.foo event') + popover.popover('show') popover.popover('destroy') + ok(!popover.hasClass('in'), 'popover is hidden') ok(!popover.data('popover'), 'popover does not have data') - ok(!popover.data('events'), 'popover does not have any events') + ok(popover.data('events').click[0].namespace == 'foo', 'popover still has click.foo') + ok(!popover.data('events').mouseover && !popover.data('events').mouseout, 'popover does not have any events') }) })
\ No newline at end of file diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js index 7852305c1..2eb8c8f7c 100644 --- a/js/tests/unit/bootstrap-tooltip.js +++ b/js/tests/unit/bootstrap-tooltip.js @@ -129,12 +129,16 @@ $(function () { }) test("should destroy tooltip", function () { - var tooltip = $('<div/>').tooltip() + var tooltip = $('<div/>').tooltip().on('click.foo', function(){}) ok(tooltip.data('tooltip'), 'tooltip has data') ok(tooltip.data('events').mouseover && tooltip.data('events').mouseout, 'tooltip has hover event') + ok(tooltip.data('events').click[0].namespace == 'foo', 'tooltip has extra click.foo event') + tooltip.tooltip('show') tooltip.tooltip('destroy') + ok(!tooltip.hasClass('in'), 'tooltip is hidden') ok(!tooltip.data('tooltip'), 'tooltip does not have data') - ok(!tooltip.data('events'), 'tooltip does not have any events') + ok(tooltip.data('events').click[0].namespace == 'foo', 'tooltip still has click.foo') + ok(!tooltip.data('events').mouseover && !tooltip.data('events').mouseout, 'tooltip does not have any events') }) }) diff --git a/js/tests/unit/bootstrap-typeahead.js b/js/tests/unit/bootstrap-typeahead.js index 25d4cafd8..eb447aaa6 100644 --- a/js/tests/unit/bootstrap-typeahead.js +++ b/js/tests/unit/bootstrap-typeahead.js @@ -181,4 +181,24 @@ $(function () { typeahead.$menu.remove() }) + + test("should start querying when minLength is met", function () { + var $input = $('<input />').typeahead({ + source: ['aaaa', 'aaab', 'aaac'], + minLength: 3 + }) + , typeahead = $input.data('typeahead') + + $input.val('aa') + typeahead.lookup() + + equals(typeahead.$menu.find('li').length, 0, 'has 0 items in menu') + + $input.val('aaa') + typeahead.lookup() + + equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu') + + typeahead.$menu.remove() + }) }) |
