Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit ec06fc1

Browse files
author
Tobias Bosch
committed
unit tests for #1851 added.
1 parent ff2ef40 commit ec06fc1

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

tests/unit/checkboxradio/checkboxradio_core.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,24 @@
2727
ok(!button.hasClass("ui-btn-active"), "no active styles after click");
2828
});
2929

30+
test( "clicking a checkbox within a controlgroup does not affect checkboxes with the same name in the same controlgroup", function(){
31+
var input1 = $("#checkbox-31");
32+
var button1 = input1.parent().find(".ui-btn");
33+
var input2 = $("#checkbox-32");
34+
var button2 = input2.parent().find(".ui-btn");
35+
36+
ok(!input1.attr("checked"), "input1 not checked before click");
37+
ok(!input2.attr("checked"), "input2 not checked before click");
38+
39+
button1.trigger("click");
40+
ok(input1.attr("checked"), "input1 checked after click on input1");
41+
ok(!input2.attr("checked"), "input2 not checked after click on input1");
42+
43+
button2.trigger("click");
44+
ok(input1.attr("checked"), "input1 not changed after click on input2");
45+
ok(input2.attr("checked"), "input2 checked after click on input2");
46+
});
47+
3048
asyncTest( "change events fired on checkbox for both check and uncheck", function(){
3149
var $checkbox = $("#checkbox-2"),
3250
$checkboxLabel = $checkbox.parent().find(".ui-btn");

tests/unit/checkboxradio/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ <h2 id="qunit-userAgent"></h2>
4141
<label for="checkbox-2">I agree</label>
4242
</fieldset>
4343
</div>
44+
45+
<div data-nstest-role="fieldcontain" data-nstest-role="controlgroup">
46+
<div>
47+
<legend>Agree to the terms 3.1:</legend>
48+
<input type="checkbox" name="checkbox-3" id="checkbox-31" class="custom"/>
49+
<label for="checkbox-31">I agree 3.1</label>
50+
</div>
51+
<div>
52+
<legend>Agree to the terms 3.2:</legend>
53+
<input type="checkbox" name="checkbox-3" id="checkbox-32" class="custom"/>
54+
<label for="checkbox-32">I agree 3.2</label>
55+
</div>
56+
</div>
4457
</div>
4558

4659
<div data-role="fieldcontain" id="radio-active-btn-test">

0 commit comments

Comments
 (0)