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/tab.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/tab.js')
| -rw-r--r-- | js/tests/unit/tab.js | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/js/tests/unit/tab.js b/js/tests/unit/tab.js index 08f6e3cfd..7372b7a17 100644 --- a/js/tests/unit/tab.js +++ b/js/tests/unit/tab.js @@ -1,19 +1,28 @@ $(function () { - module('tabs') - - test('should provide no conflict', function () { - var tab = $.fn.tab.noConflict() - ok(!$.fn.tab, 'tab was set back to undefined (org value)') - $.fn.tab = tab - }) + module('tabs plugin') test('should be defined on jquery object', function () { ok($(document.body).tab, 'tabs method is defined') }) + module('tabs', { + setup: function() { + // Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode + $.fn.bootstrapTab = $.fn.tab.noConflict() + }, + teardown: function() { + $.fn.tab = $.fn.bootstrapTab + delete $.fn.bootstrapTab + } + }) + + test('should provide no conflict', function () { + ok(!$.fn.tab, 'tab was set back to undefined (org value)') + }) + test('should return element', function () { - ok($(document.body).tab()[0] == document.body, 'document.body returned') + ok($(document.body).bootstrapTab()[0] == document.body, 'document.body returned') }) test('should activate element by tab id', function () { @@ -24,10 +33,10 @@ $(function () { $('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo('#qunit-fixture') - $(tabsHTML).find('li:last a').tab('show') + $(tabsHTML).find('li:last a').bootstrapTab('show') equal($('#qunit-fixture').find('.active').attr('id'), 'profile') - $(tabsHTML).find('li:first a').tab('show') + $(tabsHTML).find('li:first a').bootstrapTab('show') equal($('#qunit-fixture').find('.active').attr('id'), 'home') }) @@ -39,10 +48,10 @@ $(function () { $('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo('#qunit-fixture') - $(pillsHTML).find('li:last a').tab('show') + $(pillsHTML).find('li:last a').bootstrapTab('show') equal($('#qunit-fixture').find('.active').attr('id'), 'profile') - $(pillsHTML).find('li:first a').tab('show') + $(pillsHTML).find('li:first a').bootstrapTab('show') equal($('#qunit-fixture').find('.active').attr('id'), 'home') }) @@ -59,7 +68,7 @@ $(function () { .on('shown.bs.tab', function () { ok(false) }) - .tab('show') + .bootstrapTab('show') }) test('show and shown events should reference correct relatedTarget', function () { @@ -72,7 +81,7 @@ $(function () { '</li>' + '</ul>' - $(dropHTML).find('ul>li:first a').tab('show').end() + $(dropHTML).find('ul>li:first a').bootstrapTab('show').end() .find('ul>li:last a') .on('show.bs.tab', function (event) { equal(event.relatedTarget.hash, '#1-1') @@ -80,7 +89,7 @@ $(function () { .on('show.bs.tab', function (event) { equal(event.relatedTarget.hash, '#1-1') }) - .tab('show') + .bootstrapTab('show') }) }) |
