aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit
diff options
context:
space:
mode:
authorMike Vastola <[email protected]>2018-12-10 03:40:08 -0500
committerXhmikosR <[email protected]>2018-12-10 10:40:08 +0200
commitfc15c4c4ce132e70eb67335dfe840c3f0a80dae4 (patch)
tree7fd8b5c63efdbfb5d96670c648cb00300d850e90 /js/tests/unit
parent385ce1c961b4acfbe11f7029542a7df83075725c (diff)
downloadbootstrap-fc15c4c4ce132e70eb67335dfe840c3f0a80dae4.tar.xz
bootstrap-fc15c4c4ce132e70eb67335dfe840c3f0a80dae4.zip
Change button checkbox/radios to ignore hidden input fields (#27802)
Diffstat (limited to 'js/tests/unit')
-rw-r--r--js/tests/unit/button.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js
index 9576dd256..724545a53 100644
--- a/js/tests/unit/button.js
+++ b/js/tests/unit/button.js
@@ -139,6 +139,29 @@ $(function () {
assert.ok($btn2.find('input').prop('checked'), 'btn2 is checked')
})
+ QUnit.test('should only toggle selectable inputs', function (assert) {
+ assert.expect(6)
+ var groupHTML = '<div class="btn-group" data-toggle="buttons">' +
+ '<label class="btn btn-primary active">' +
+ '<input type="hidden" name="option1" id="option1-default" value="false">' +
+ '<input type="checkbox" name="option1" id="option1" checked="true"> Option 1' +
+ '</label>' +
+ '</div>'
+ var $group = $(groupHTML).appendTo('#qunit-fixture')
+
+ var $btn = $group.children().eq(0)
+ var $hidden = $btn.find('input#option1-default')
+ var $cb = $btn.find('input#option1')
+
+ assert.ok($btn.hasClass('active'), 'btn has active class')
+ assert.ok($cb.prop('checked'), 'btn is checked')
+ assert.ok(!$hidden.prop('checked'), 'hidden is not checked')
+ $btn.trigger('click')
+ assert.ok(!$btn.hasClass('active'), 'btn does not have active class')
+ assert.ok(!$cb.prop('checked'), 'btn is not checked')
+ assert.ok(!$hidden.prop('checked'), 'hidden is not checked') // should not be changed
+ })
+
QUnit.test('should not add aria-pressed on labels for radio/checkbox inputs in a data-toggle="buttons" group', function (assert) {
assert.expect(2)
var groupHTML = '<div class="btn-group" data-toggle="buttons">' +