Skip to content

Commit ba3becb

Browse files
committed
Button: Fixup deprecated tests
1 parent da1ef13 commit ba3becb

File tree

5 files changed

+67
-78
lines changed

5 files changed

+67
-78
lines changed

tests/unit/button/button_core_deprecated.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/unit/button/button_deprecated.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@
2727
<script src="button_events.js"></script>
2828
<script src="button_methods.js"></script>
2929
<script src="button_options.js"></script>
30-
<script src="button_core_deprecated.js"></script>
30+
<script src="button_deprecated.js"></script>
3131
<script src="button_common_deprecated.js"></script>
32-
<script src="button_methods_deprecated.js"></script>
33-
<script src="button_options_deprecated.js"></script>
3432
<script src="../swarminject.js"></script>
3533
</head>
3634
<body>

tests/unit/button/button_options_deprecated.js renamed to tests/unit/button/button_deprecated.js

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,65 @@
11
/*
2-
* button_options_deprecated.js
2+
* button_core.js
33
*/
4+
5+
46
(function($) {
57

6-
module( "button: options deprecated" );
8+
module( "Button (deprecated): core" );
9+
10+
test( "Calling button on a checkbox input calls checkboxradio widget", function(){
11+
var checkbox = $( "#checkbox01" );
12+
13+
expect( 2 );
14+
checkbox.button();
15+
16+
ok( checkbox.is( ":ui-checkboxradio" ),
17+
"Calling button on a checkbox creates checkboxradio instance" );
18+
ok( !checkbox.checkboxradio( "option", "icon" ),
19+
"Calling button on a checkbox sets the checkboxradio icon option to false" );
20+
});
21+
22+
test( "Calling buttonset calls controlgroup", function(){
23+
var controlgroup = $( ".buttonset" );
24+
25+
expect( 1 );
26+
controlgroup.buttonset();
27+
28+
ok( controlgroup.is( ":ui-controlgroup" ), "Calling buttonset creates controlgroup instance" );
29+
});
30+
31+
module( "Button (deprecated): methods" );
32+
33+
test( "destroy", function() {
34+
expect( 1 );
35+
domEqual( "#checkbox02", function() {
36+
$( "#checkbox02" ).button().button( "destroy" );
37+
});
38+
});
39+
40+
test( "refresh: Ensure disabled state is preserved correctly.", function() {
41+
expect( 4 );
42+
var element = null;
43+
44+
element = $( "#checkbox02" );
45+
element.button( { disabled: true } ).button( "refresh" );
46+
ok( element.button( "option", "disabled" ), "Checkboxes should remain disabled after refresh");
47+
48+
element = $( "#radio02" );
49+
element.button( { disabled: true } ).button( "refresh" );
50+
ok( element.button( "option", "disabled" ), "Radio buttons should remain disabled after refresh");
51+
52+
element = $( "#checkbox02" );
53+
element.button( { disabled: true} ).prop( "disabled", false ).button( "refresh" );
54+
ok( !element.button( "option", "disabled" ), "Changing a checkbox's disabled property should update the state after refresh.");
55+
56+
element = $( "#radio02" );
57+
element.button( { disabled: true} ).prop( "disabled", false ).button( "refresh" );
58+
ok( !element.button( "option", "disabled" ), "Changing a radio button's disabled property should update the state after refresh.");
59+
60+
});
61+
62+
module( "button (deprecated): options" );
763

864
test( "Setting items option on button set sets the button properties on the items option", function() {
965
expect( 2 );
@@ -138,4 +194,4 @@ test( "icon and icons options properly proxied", function(){
138194
"Icons secondary option sets iconPosition option to end on init" );
139195
});
140196

141-
})(jQuery);
197+
})(jQuery);

tests/unit/button/button_methods_deprecated.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

tests/unit/button/core.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ test( "input type submit, don't create child elements", function() {
1313
equal( input.children().length, 0 );
1414
});
1515

16-
asyncTest( "Disabled button maintains ui-state-focus", function() {
17-
expect( 1 );
16+
asyncTest( "Disabled button loses focus", function() {
17+
expect( 2 );
1818
var element = $( "#button" ).button();
19-
element.simulate( "focus" );
19+
20+
element.focus();
2021
setTimeout(function() {
2122

22-
// Todo: figure out why this fails in phantom put passes in browser
23-
// ok( element.is( ":focus" ), "Button is focused" );
23+
ok( element.is( document.activeElement ), "Button is focused" );
24+
2425
element.button( "disable" );
25-
ok( !element.is( ":focus" ), "Button has had focus removed" );
26+
ok( !element.is( document.activeElement ), "Button has had focus removed" );
2627
start();
2728
});
2829
});

0 commit comments

Comments
 (0)