aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit/button.js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2013-12-14 15:38:21 -0800
committerMark Otto <[email protected]>2013-12-14 15:38:21 -0800
commita54dbfdf2a08ff04fc65f8e4f77ee5dc76bf4ef3 (patch)
tree9b1c5697a731543a86711b016e1986ec1e81dad4 /js/tests/unit/button.js
parent80e86442308b2cc86ba948de87e854057933e3ab (diff)
parentf1869771bc8b8e8a6c7a98385ec58e0bf0d2d98e (diff)
downloadbootstrap-a54dbfdf2a08ff04fc65f8e4f77ee5dc76bf4ef3.tar.xz
bootstrap-a54dbfdf2a08ff04fc65f8e4f77ee5dc76bf4ef3.zip
Merge branch 'master' into pr/10951
Conflicts: dist/css/bootstrap.min.css less/modals.less
Diffstat (limited to 'js/tests/unit/button.js')
-rw-r--r--js/tests/unit/button.js36
1 files changed, 21 insertions, 15 deletions
diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js
index 41ddb5c2f..45397aeff 100644
--- a/js/tests/unit/button.js
+++ b/js/tests/unit/button.js
@@ -1,26 +1,26 @@
$(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>')
- equals(btn.html(), 'mdo', 'btn text equals mdo')
+ equal(btn.html(), 'mdo', 'btn text equals mdo')
btn.button('loading')
- equals(btn.html(), 'fat', 'btn text equals fat')
+ equal(btn.html(), 'fat', 'btn text equals fat')
stop()
setTimeout(function () {
ok(btn.attr('disabled'), 'btn is disabled')
@@ -29,11 +29,11 @@ $(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>')
- equals(btn.html(), 'mdo', 'btn text equals mdo')
+ equal(btn.html(), 'mdo', 'btn text equals mdo')
btn.button('loading')
- equals(btn.html(), 'fat', 'btn text equals fat')
+ equal(btn.html(), 'fat', 'btn text equals fat')
stop()
setTimeout(function () {
ok(btn.attr('disabled'), 'btn is disabled')
@@ -41,7 +41,7 @@ $(function () {
start()
stop()
btn.button('reset')
- equals(btn.html(), 'mdo', 'btn text equals mdo')
+ equal(btn.html(), 'mdo', 'btn text equals mdo')
setTimeout(function () {
ok(!btn.attr('disabled'), 'btn is not disabled')
ok(!btn.hasClass('disabled'), 'btn does not have disabled class')
@@ -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')
})
})