diff options
| author | Collin Donahue-Oponski <[email protected]> | 2014-04-21 23:03:33 -0600 |
|---|---|---|
| committer | Collin Donahue-Oponski <[email protected]> | 2014-04-21 23:03:33 -0600 |
| commit | a9f2b6ce0fb2ac059e30da259f7ae25282803c09 (patch) | |
| tree | 33aa8358b29db57532dbf2d8560649c7e11f2628 /js/tests/unit/dropdown.js | |
| parent | 9c4afc577253ada54d3ff27965e380a5c9f4e60e (diff) | |
| download | bootstrap-a9f2b6ce0fb2ac059e30da259f7ae25282803c09.tar.xz bootstrap-a9f2b6ce0fb2ac059e30da259f7ae25282803c09.zip | |
#11464 - Fix JS noConflict mode - Refactor all plugins to use an internal reference to the jQuery plugin, because in noConflict mode you can never expect to be defined on the jQuery object
Diffstat (limited to 'js/tests/unit/dropdown.js')
| -rw-r--r-- | js/tests/unit/dropdown.js | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js index 2d2e7c51d..f074c5598 100644 --- a/js/tests/unit/dropdown.js +++ b/js/tests/unit/dropdown.js @@ -1,20 +1,29 @@ $(function () { - module('dropdowns') - - test('should provide no conflict', function () { - var dropdown = $.fn.dropdown.noConflict() - ok(!$.fn.dropdown, 'dropdown was set back to undefined (org value)') - $.fn.dropdown = dropdown - }) + module('dropdowns plugin') test('should be defined on jquery object', function () { ok($(document.body).dropdown, 'dropdown method is defined') }) + module('dropdowns', { + setup: function() { + // Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode + $.fn.bootstrapDropdown = $.fn.dropdown.noConflict() + }, + teardown: function() { + $.fn.dropdown = $.fn.bootstrapDropdown + delete $.fn.bootstrapDropdown + } + }) + + test('should provide no conflict', function () { + ok(!$.fn.dropdown, 'dropdown was set back to undefined (org value)') + }) + test('should return element', function () { var el = $('<div />') - ok(el.dropdown()[0] === el[0], 'same element returned') + ok(el.bootstrapDropdown()[0] === el[0], 'same element returned') }) test('should not open dropdown if target is disabled', function () { @@ -29,7 +38,7 @@ $(function () { '</ul>' + '</li>' + '</ul>', - dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').dropdown().click() + dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click() ok(!dropdown.parent('.dropdown').hasClass('open'), 'open class added on click') }) @@ -46,7 +55,7 @@ $(function () { '</ul>' + '</li>' + '</ul>', - dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').dropdown().click() + dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click() ok(!dropdown.parent('.dropdown').hasClass('open'), 'open class added on click') }) @@ -63,7 +72,7 @@ $(function () { '</ul>' + '</li>' + '</ul>', - dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').dropdown().click() + dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click() ok(dropdown.parent('.dropdown').hasClass('open'), 'open class added on click') }) @@ -80,7 +89,7 @@ $(function () { '</ul>' + '</li>' + '</ul>', - dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').dropdown().click() + dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click() ok(dropdown.parent('.dropdown').hasClass('open'), 'open class added on click') }) @@ -101,7 +110,7 @@ $(function () { dropdown = $(dropdownHTML) .appendTo('#qunit-fixture') .find('[data-toggle="dropdown"]') - .dropdown() + .bootstrapDropdown() .click() ok(dropdown.parent('.dropdown').hasClass('open'), 'open class added on click') @@ -163,7 +172,7 @@ $(function () { dropdown = $(dropdownHTML) .appendTo('#qunit-fixture') .find('[data-toggle="dropdown"]') - .dropdown() + .bootstrapDropdown() stop() @@ -197,7 +206,7 @@ $(function () { dropdown = $(dropdownHTML) .appendTo('#qunit-fixture') .find('[data-toggle="dropdown"]') - .dropdown() + .bootstrapDropdown() stop() |
