aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit/button.js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2013-12-14 16:46:40 -0800
committerMark Otto <[email protected]>2013-12-14 16:46:40 -0800
commit4c64c1eecdb52d943a50d2c181aeb915a3caed34 (patch)
tree93b556ef583bb6a327cad76804bbdf4c5a4c6f4c /js/tests/unit/button.js
parent2b56ff04614c4617355d16c14784654e841bcf4d (diff)
parentd79431ca02683c9d1c754201260f66e5dda15614 (diff)
downloadbootstrap-4c64c1eecdb52d943a50d2c181aeb915a3caed34.tar.xz
bootstrap-4c64c1eecdb52d943a50d2c181aeb915a3caed34.zip
Merge branch 'master' into pr/11302
Conflicts: dist/css/bootstrap.css dist/css/bootstrap.min.css
Diffstat (limited to 'js/tests/unit/button.js')
-rw-r--r--js/tests/unit/button.js26
1 files changed, 16 insertions, 10 deletions
diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js
index 16284e0ce..45397aeff 100644
--- a/js/tests/unit/button.js
+++ b/js/tests/unit/button.js
@@ -1,22 +1,22 @@
$(function () {
- module("button")
+ module('button')
- test("should provide no conflict", function () {
+ 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
})
- test("should be defined on jquery object", function () {
+ test('should be defined on jquery object', function () {
ok($(document.body).button, 'button method is defined')
})
- test("should return element", function () {
+ test('should return element', function () {
ok($(document.body).button()[0] == document.body, 'document.body returned')
})
- test("should return set state to loading", function () {
+ 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')
@@ -29,7 +29,7 @@ $(function () {
}, 0)
})
- test("should return reset state", 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')
@@ -51,14 +51,14 @@ $(function () {
})
- test("should toggle active", 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')
ok(btn.hasClass('active'), 'btn has class active')
})
- test("should toggle active when btn children are clicked", function () {
+ test('should toggle active when btn children are clicked', function () {
var btn = $('<button class="btn" data-toggle="button">mdo</button>')
, inner = $('<i></i>')
btn
@@ -69,7 +69,7 @@ $(function () {
ok(btn.hasClass('active'), 'btn has class active')
})
- test("should toggle active when btn children are clicked within btn-group", function () {
+ test('should toggle active when btn children are clicked within btn-group', function () {
var btngroup = $('<div class="btn-group" data-toggle="buttons"></div>')
, btn = $('<button class="btn">fat</button>')
, inner = $('<i></i>')
@@ -81,7 +81,7 @@ $(function () {
ok(btn.hasClass('active'), 'btn has class active')
})
- test("should check for closest matching toggle", function () {
+ test('should check for closest matching toggle', function () {
var group = '<div class="btn-group" data-toggle="buttons">' +
'<label class="btn btn-primary active">' +
'<input type="radio" name="options" id="option1" checked="true"> Option 1' +
@@ -111,6 +111,12 @@ $(function () {
ok(!btn1.find('input').prop('checked'), 'btn1 is checked')
ok(btn2.hasClass('active'), 'btn2 has active class')
ok(btn2.find('input').prop('checked'), 'btn2 is checked')
+
+ btn2.find('input').click() /* clicking an already checked radio should not un-check it */
+ ok(!btn1.hasClass('active'), 'btn1 does not have active class')
+ ok(!btn1.find('input').prop('checked'), 'btn1 is checked')
+ ok(btn2.hasClass('active'), 'btn2 has active class')
+ ok(btn2.find('input').prop('checked'), 'btn2 is checked')
})
})