Skip to content

Commit d3b0f85

Browse files
committed
Checkboxradio: add option and method tests
1 parent 661ce0e commit d3b0f85

File tree

11 files changed

+404
-67
lines changed

11 files changed

+404
-67
lines changed

demos/button/checkbox.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
}
2828
checkboxes.checkboxradio( "option", option, value );
2929
});
30-
$( "#create" ).click( function(){
30+
$( ".controls>button" ).click( function(){
3131
if( this.id !== "create" ){
3232
checkboxes.checkboxradio( this.id );
3333
} else {
@@ -57,11 +57,11 @@
5757
<form>
5858
<input type="checkbox" id="checkbox-1" />
5959
<label for="checkbox-1">Checkbox widget sample</label>
60-
<label for="checkbox-2">Checkbox widget sample<input type="checkbox" id="checkbox-2" /></label>
60+
<input type="checkbox" id="checkbox-2" /><label for="checkbox-2">Checkbox widget sample</label>
6161

6262
<input type="radio" id="radio-1" name="radio" checked/>
6363
<label for="radio-1">Radio widget sample</label>
64-
<label for="radio-2">Radio widget sample 2<input type="radio" id="radio-2" name="radio"/></label>
64+
<input type="radio" id="radio-2" name="radio"/><label for="radio-2">Radio widget sample 2</label>
6565
<button type="reset">Reset</button>
6666
</form>
6767
</div>

tests/unit/button/button_core.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@
55

66
(function($) {
77

8-
module("button: core");
8+
module( "Button: core" );
99

10-
test("input type submit, don't create child elements", function() {
10+
test( "Input type submit, don't create child elements", function() {
1111
expect( 2 );
1212
var input = $("#submit");
1313
deepEqual( input.children().length, 0 );
1414
input.button();
1515
deepEqual( input.children().length, 0 );
1616
});
1717

18-
asyncTest( "#9169 - Disabled button maintains ui-state-focus", function() {
18+
asyncTest( "Disabled button maintains ui-state-focus", function() {
1919
expect( 2 );
2020
var element = $( "#button1" ).button();
2121
element.simulate( "focus" );
2222
setTimeout(function() {
23-
ok( element.is( ":focus" ), "button is focused" );
23+
ok( element.is( ":focus" ), "Button is focused" );
2424
element.button( "disable" );
2525
ok( !element.is( ":focus" ),
26-
"button has had focus removed" );
26+
"Button has had focus removed" );
2727
start();
2828
});
2929
});

tests/unit/button/button_events.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
*/
44
(function($) {
55

6-
module("button: events");
6+
module( "Button: events" );
77

8-
asyncTest( "when button loses focus, ensure active state is removed (#8559)", function() {
8+
asyncTest( "When button loses focus, ensure active state is removed", function() {
99
expect( 1 );
1010

1111
var element = $( "#button" ).button();
1212

1313
element.one( "keypress", function() {
1414
element.one( "blur", function() {
15-
ok( !element.is(".ui-state-active"), "button loses active state appropriately" );
15+
ok( !element.is( ".ui-state-active" ), "button loses active state appropriately" );
1616
start();
1717
}).blur();
1818
});

tests/unit/button/button_methods.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
(function($) {
55

66

7-
module("button: methods");
7+
module( "Button: methods" );
88

9-
test("destroy", function() {
9+
test( "destroy", function() {
1010
expect( 1 );
1111
domEqual( "#button", function() {
1212
$( "#button" ).button().button( "destroy" );

tests/unit/button/button_options.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,27 @@ test( "disabled, explicit value", function() {
2525
deepEqual( element.prop( "disabled" ), true, "element is not disabled" );
2626
});
2727

28-
test("disabled, null", function() {
28+
test( "disabled, null", function() {
2929
expect( 4 );
30-
$("#radio01").button({ disabled: null });
30+
$( "#radio01" ).button({ disabled: null });
3131
strictEqual( $("#radio01").button("option", "disabled"), false,
3232
"disabled option set to false");
3333
strictEqual( $("#radio01").prop("disabled"), false, "element is disabled");
3434

35-
$("#radio02").prop("disabled", true).button({ disabled: null });
36-
deepEqual(true, $("#radio02").button("option", "disabled"),
37-
"disabled option set to true");
38-
deepEqual(true, $("#radio02").prop("disabled"), "element is not disabled");
35+
$( "#radio02" ).prop( "disabled", true ).button({ disabled: null });
36+
deepEqual( true, $( "#radio02" ).button( "option", "disabled" ),
37+
"disabled option set to true" );
38+
deepEqual( true, $( "#radio02" ).prop( "disabled" ), "element is not disabled" );
3939
});
4040

41-
test("showLabel false without icon", function() {
41+
test( "showLabel false without icon", function() {
4242
expect( 1 );
43-
$("#button").button({
43+
$( "#button" ).button({
4444
showLabel: false
4545
});
46-
strictEqual( $("#button").attr( "class" ), "ui-button ui-widget ui-corner-all" );
46+
strictEqual( $( "#button" ).attr( "class" ), "ui-button ui-widget ui-corner-all" );
4747

48-
$("#button").button("destroy");
48+
$( "#button" ).button( "destroy" );
4949
});
5050

5151
test("showLabel false with icon", function() {
@@ -54,55 +54,55 @@ test("showLabel false with icon", function() {
5454
showLabel: false,
5555
icon: "iconclass"
5656
});
57-
strictEqual( $("#button").attr( "class" ), "ui-button ui-widget ui-corner-all ui-icon-beginning ui-button-icon-only" );
57+
strictEqual( $( "#button" ).attr( "class" ), "ui-button ui-widget ui-corner-all ui-icon-beginning ui-button-icon-only" );
5858

59-
$("#button").button("destroy");
59+
$( "#button" ).button( "destroy" );
6060
});
6161

62-
test("label, default", function() {
62+
test( "label, default", function() {
6363
expect( 2 );
64-
$("#button").button();
65-
deepEqual( $("#button").text(), "Label" );
66-
deepEqual( $( "#button").button( "option", "label" ), "Label" );
64+
$( "#button" ).button();
65+
deepEqual( $( "#button" ).text(), "Label" );
66+
deepEqual( $( "#button" ).button( "option", "label" ), "Label" );
6767

68-
$("#button").button("destroy");
68+
$( "#button" ).button( "destroy" );
6969
});
7070

71-
test("label", function() {
71+
test( "label", function() {
7272
expect( 2 );
73-
$("#button").button({
73+
$( "#button" ).button({
7474
label: "xxx"
7575
});
76-
deepEqual( $("#button").text(), "xxx" );
77-
deepEqual( $("#button").button( "option", "label" ), "xxx" );
76+
deepEqual( $( "#button" ).text(), "xxx" );
77+
deepEqual( $( "#button" ).button( "option", "label" ), "xxx" );
7878

79-
$("#button").button("destroy");
79+
$( "#button" ).button( "destroy" );
8080
});
8181

82-
test("label default with input type submit", function() {
82+
test( "label default with input type submit", function() {
8383
expect( 2 );
84-
deepEqual( $("#submit").button().val(), "Label" );
85-
deepEqual( $("#submit").button( "option", "label" ), "Label" );
84+
deepEqual( $( "#submit" ).button().val(), "Label" );
85+
deepEqual( $( "#submit" ).button( "option", "label" ), "Label" );
8686
});
8787

88-
test("label with input type submit", function() {
88+
test( "label with input type submit", function() {
8989
expect( 2 );
90-
var label = $("#submit").button({
90+
var label = $( "#submit" ).button({
9191
label: "xxx"
9292
}).val();
9393
deepEqual( label, "xxx" );
94-
deepEqual( $("#submit").button( "option", "label" ), "xxx" );
94+
deepEqual( $( "#submit" ).button( "option", "label" ), "xxx" );
9595
});
9696

97-
test("icons", function() {
97+
test( "icons", function() {
9898
expect( 1 );
9999
$("#button").button({
100100
showLabel: false,
101101
icon: "iconclass"
102102
});
103-
strictEqual( $("#button").find("span.ui-icon.iconclass").length, 1 );
103+
strictEqual( $( "#button" ).find( "span.ui-icon.iconclass" ).length, 1 );
104104

105-
$("#button").button("destroy");
105+
$( "#button" ).button( "destroy" );
106106
});
107107

108108
})(jQuery);

tests/unit/checkboxradio/checkboxradio.html

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
<script src="checkboxradio_common.js"></script>
2424
<script src="checkboxradio_core.js"></script>
25-
25+
<script src="checkboxradio_methods.js"></script>
26+
<script src="checkboxradio_options.js"></script>
2627
<script src="../swarminject.js"></script>
2728
</head>
2829
<body>
@@ -59,7 +60,26 @@
5960

6061
<input type="checkbox" id="check"><label for="check">Toggle</label>
6162
<input type="checkbox" id="check2"><label for="check2">Checkbox</label>
63+
<label for="checkbox-method-refresh" id="checkbox-method-refresh-label">checkbox refresh</label>
64+
<input type="checkbox" id="checkbox-method-refresh"/>
65+
<label for="checkbox-method-destroy" class="bar" id="checkbox-method-destroy-label">checkbox refresh</label>
66+
<input type="checkbox" class="foo" id="checkbox-method-destroy"/>
67+
<label for="checkbox-method-disable">checkbox refresh</label>
68+
<input type="checkbox" class="foo" id="checkbox-method-disable"/>
69+
70+
<label for="radio-method-refresh" id="radio-method-refresh-label">radio refresh</label>
71+
<input type="radio" id="radio-method-refresh"/>
72+
<label for="radio-method-destroy" class="bar" id="radio-method-destroy-label">radio refresh</label>
73+
<input type="radio" class="foo" id="radio-method-destroy"/>
74+
<label for="radio-method-disable">radio refresh</label>
75+
<input type="radio" class="foo" id="radio-method-disable"/>
6276

77+
<label for="checkbox-option-disabled">checkbox disabled</label>
78+
<input type="checkbox" class="foo" id="checkbox-option-disabled"/>
79+
<label for="checkbox-option-icon">checkbox icon</label>
80+
<input type="checkbox" class="foo" id="checkbox-option-icon"/>
81+
<label for="checkbox-option-label">checkbox label</label>
82+
<input type="checkbox" class="foo" id="checkbox-option-label"/>
6383
</div>
6484
</body>
6585
</html>

tests/unit/checkboxradio/checkboxradio_core.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*
2-
* button_core.js
2+
* checkboxradio_core.js
33
*/
44

55

66
(function($) {
77

8-
module("checkboxradio: core");
9-
test("checkbox", function() {
8+
module("Checkboxradio: core");
9+
test("Checkbox", function() {
1010
expect( 4 );
1111
var input = $("#check"),
1212
label = $("label[for=check]");
@@ -17,7 +17,7 @@ test("checkbox", function() {
1717
strictEqual( label.attr( "class" ), "ui-button ui-widget ui-corner-all ui-checkbox-label" );
1818
});
1919

20-
test("radios", function() {
20+
test("Radios", function() {
2121
expect( 4 );
2222
var inputs = $("#radio0 input"),
2323
labels = $("#radio0 label");
@@ -68,7 +68,7 @@ asyncTest( "Checkbox/Radiobutton do not Show Focused State when using Keyboard N
6868
// remove this when simulate properly simulates this
6969
// see http://yuilibrary.com/projects/yui2/ticket/2528826 fore more info
7070
if ( !$.ui.ie || ( document.documentMode && document.documentMode > 8 ) ) {
71-
asyncTest( "ensure checked and aria after single click on checkbox label button, see #5518", function() {
71+
asyncTest( "Ensure checked after single click on checkbox label button", function() {
7272
expect( 2 );
7373

7474
$( "#check2" ).checkboxradio().change( function() {
@@ -90,7 +90,7 @@ if ( !$.ui.ie || ( document.documentMode && document.documentMode > 8 ) ) {
9090
}, 1 );
9191
});
9292
}
93-
test( "button creation that requires a matching label does not find label in all cases", function() {
93+
test( "Checkbox creation that requires a matching label does not find label in all cases", function() {
9494
expect( 5 );
9595
var group = $( "<span><label for='t7092a'></label><input type='checkbox' id='t7092a'></span>" );
9696
group.find( "input[type=checkbox]" ).checkboxradio();
@@ -130,7 +130,7 @@ asyncTest( "Resetting a button's form should refresh the visual state of the but
130130
start();
131131
}, 1 );
132132
});
133-
test( "#7534 - Checkbox label selector works for ids with \":\"", function() {
133+
test( "Checkbox label selector works for ids with \":\"", function() {
134134
expect( 1 );
135135
var group = $( "<span><input type='checkbox' id='check:7534'><label for='check:7534'>Label</label></span>" );
136136
group.find( "input" ).checkboxradio();

0 commit comments

Comments
 (0)