aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit/button.js
diff options
context:
space:
mode:
authorCollin Donahue-Oponski <[email protected]>2014-04-21 23:03:33 -0600
committerCollin Donahue-Oponski <[email protected]>2014-04-21 23:03:33 -0600
commita9f2b6ce0fb2ac059e30da259f7ae25282803c09 (patch)
tree33aa8358b29db57532dbf2d8560649c7e11f2628 /js/tests/unit/button.js
parent9c4afc577253ada54d3ff27965e380a5c9f4e60e (diff)
downloadbootstrap-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/button.js')
-rw-r--r--js/tests/unit/button.js33
1 files changed, 21 insertions, 12 deletions
diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js
index ea1236478..10bff1442 100644
--- a/js/tests/unit/button.js
+++ b/js/tests/unit/button.js
@@ -1,25 +1,34 @@
$(function () {
- module('button')
-
- test('should provide no conflict', function () {
- var button = $.fn.button.noConflict()
- ok(!$.fn.button, 'button was set back to undefined (org value)')
- $.fn.button = button
- })
+ module('button plugin')
test('should be defined on jquery object', function () {
ok($(document.body).button, 'button method is defined')
})
+ module('button', {
+ setup: function() {
+ // Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
+ $.fn.bootstrapButton = $.fn.button.noConflict()
+ },
+ teardown: function() {
+ $.fn.button = $.fn.bootstrapButton
+ delete $.fn.bootstrapButton
+ }
+ })
+
+ test('should provide no conflict', function () {
+ ok(!$.fn.button, 'button was set back to undefined (org value)')
+ })
+
test('should return element', function () {
- ok($(document.body).button()[0] == document.body, 'document.body returned')
+ ok($(document.body).bootstrapButton()[0] == document.body, 'document.body returned')
})
test('should return set state to loading', function () {
var btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
equal(btn.html(), 'mdo', 'btn text equals mdo')
- btn.button('loading')
+ btn.bootstrapButton('loading')
equal(btn.html(), 'fat', 'btn text equals fat')
stop()
setTimeout(function () {
@@ -32,7 +41,7 @@ $(function () {
test('should return reset state', function () {
var btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
equal(btn.html(), 'mdo', 'btn text equals mdo')
- btn.button('loading')
+ btn.bootstrapButton('loading')
equal(btn.html(), 'fat', 'btn text equals fat')
stop()
setTimeout(function () {
@@ -40,7 +49,7 @@ $(function () {
ok(btn.hasClass('disabled'), 'btn has disabled class')
start()
stop()
- btn.button('reset')
+ btn.bootstrapButton('reset')
equal(btn.html(), 'mdo', 'btn text equals mdo')
setTimeout(function () {
ok(!btn.attr('disabled'), 'btn is not disabled')
@@ -54,7 +63,7 @@ $(function () {
test('should toggle active', function () {
var btn = $('<button class="btn">mdo</button>')
ok(!btn.hasClass('active'), 'btn does not have active class')
- btn.button('toggle')
+ btn.bootstrapButton('toggle')
ok(btn.hasClass('active'), 'btn has class active')
})