1
1
define ( [
2
+ "qunit" ,
2
3
"jquery" ,
3
4
"ui/widgets/button"
4
- ] , function ( $ ) {
5
+ ] , function ( QUnit , $ ) {
5
6
6
- module ( "Button (deprecated): core" ) ;
7
+ QUnit . module ( "Button (deprecated): core" ) ;
7
8
8
- test ( "Calling button on a checkbox input calls checkboxradio widget" , function ( ) {
9
+ QUnit . test ( "Calling button on a checkbox input calls checkboxradio widget" , function ( assert ) {
9
10
var checkbox = $ ( "#checkbox01" ) ;
10
11
11
- expect ( 2 ) ;
12
+ assert . expect ( 2 ) ;
12
13
checkbox . button ( ) ;
13
14
14
- ok ( ! ! checkbox . checkboxradio ( "instance" ) ,
15
+ assert . ok ( ! ! checkbox . checkboxradio ( "instance" ) ,
15
16
"Calling button on a checkbox creates checkboxradio instance" ) ;
16
- ok ( ! checkbox . checkboxradio ( "option" , "icon" ) ,
17
+ assert . ok ( ! checkbox . checkboxradio ( "option" , "icon" ) ,
17
18
"Calling button on a checkbox sets the checkboxradio icon option to false" ) ;
18
19
} ) ;
19
20
20
- test ( "Calling buttonset calls controlgroup" , function ( ) {
21
+ QUnit . test ( "Calling buttonset calls controlgroup" , function ( assert ) {
21
22
var controlgroup = $ ( ".buttonset" ) ;
22
23
23
- expect ( 1 ) ;
24
+ assert . expect ( 1 ) ;
24
25
controlgroup . buttonset ( ) ;
25
26
26
- ok ( controlgroup . is ( ":ui-controlgroup" ) , "Calling buttonset creates controlgroup instance" ) ;
27
+ assert . ok ( controlgroup . is ( ":ui-controlgroup" ) , "Calling buttonset creates controlgroup instance" ) ;
27
28
} ) ;
28
29
29
- module ( "Button (deprecated): methods" ) ;
30
+ QUnit . module ( "Button (deprecated): methods" ) ;
30
31
31
- test ( "destroy" , function ( assert ) {
32
- expect ( 1 ) ;
32
+ QUnit . test ( "destroy" , function ( assert ) {
33
+ assert . expect ( 1 ) ;
33
34
assert . domEqual ( "#checkbox02" , function ( ) {
34
35
$ ( "#checkbox02" ) . button ( ) . button ( "destroy" ) ;
35
36
} ) ;
36
37
} ) ;
37
38
38
- test ( "refresh: Ensure disabled state is preserved correctly." , function ( ) {
39
- expect ( 5 ) ;
39
+ QUnit . test ( "refresh: Ensure disabled state is preserved correctly." , function ( assert ) {
40
+ assert . expect ( 5 ) ;
40
41
var element = null ;
41
42
42
43
element = $ ( "#checkbox02" ) ;
43
44
element . button ( { disabled : true } ) . button ( "refresh" ) ;
44
- ok ( element . button ( "option" , "disabled" ) , "Checkboxes should remain disabled after refresh" ) ;
45
- ok ( element . prop ( "disabled" ) , "Input remains disabled after refresh" ) ;
45
+ assert . ok ( element . button ( "option" , "disabled" ) , "Checkboxes should remain disabled after refresh" ) ;
46
+ assert . ok ( element . prop ( "disabled" ) , "Input remains disabled after refresh" ) ;
46
47
47
48
element = $ ( "#radio02" ) ;
48
49
element . button ( { disabled : true } ) . button ( "refresh" ) ;
49
- ok ( element . button ( "option" , "disabled" ) , "Radio buttons should remain disabled after refresh" ) ;
50
+ assert . ok ( element . button ( "option" , "disabled" ) , "Radio buttons should remain disabled after refresh" ) ;
50
51
51
52
element = $ ( "#checkbox02" ) ;
52
53
element . button ( { disabled : true } ) . prop ( "disabled" , false ) . button ( "refresh" ) ;
53
- ok ( ! element . button ( "option" , "disabled" ) , "Changing a checkbox's disabled property should update the state after refresh." ) ;
54
+ assert . ok ( ! element . button ( "option" , "disabled" ) , "Changing a checkbox's disabled property should update the state after refresh." ) ;
54
55
55
56
element = $ ( "#radio02" ) ;
56
57
element . button ( { disabled : true } ) . prop ( "disabled" , false ) . button ( "refresh" ) ;
57
- ok ( ! element . button ( "option" , "disabled" ) , "Changing a radio button's disabled property should update the state after refresh." ) ;
58
+ assert . ok ( ! element . button ( "option" , "disabled" ) , "Changing a radio button's disabled property should update the state after refresh." ) ;
58
59
59
60
} ) ;
60
61
61
- module ( "button (deprecated): options" ) ;
62
+ QUnit . module ( "button (deprecated): options" ) ;
62
63
63
- test ( "Setting items option on buttonset sets the button properties on the items option" , function ( ) {
64
- expect ( 2 ) ;
64
+ QUnit . test ( "Setting items option on buttonset sets the button properties on the items option" , function ( assert ) {
65
+ assert . expect ( 2 ) ;
65
66
66
67
var controlgroup = $ ( ".buttonset" ) ;
67
68
68
69
controlgroup . buttonset ( { items : "bar" } ) ;
69
- equal ( controlgroup . controlgroup ( "option" , "items.button" ) , "bar" ,
70
+ assert . equal ( controlgroup . controlgroup ( "option" , "items.button" ) , "bar" ,
70
71
"items.button set when setting items option on init on buttonset" ) ;
71
72
72
73
controlgroup . buttonset ( "option" , "items" , "foo" ) ;
73
- equal ( controlgroup . controlgroup ( "option" , "items.button" ) , "foo" ,
74
+ assert . equal ( controlgroup . controlgroup ( "option" , "items.button" ) , "foo" ,
74
75
"items.button set when setting items option on buttonset" ) ;
75
76
} ) ;
76
77
77
- test ( "disabled, null" , function ( ) {
78
- expect ( 2 ) ;
78
+ QUnit . test ( "disabled, null" , function ( assert ) {
79
+ assert . expect ( 2 ) ;
79
80
80
81
$ ( "#radio02" ) . prop ( "disabled" , true ) . button ( { disabled : null } ) ;
81
- deepEqual ( $ ( "#radio02" ) . button ( "option" , "disabled" ) , true ,
82
+ assert . deepEqual ( $ ( "#radio02" ) . button ( "option" , "disabled" ) , true ,
82
83
"disabled option set to true" ) ;
83
- deepEqual ( true , $ ( "#radio02" ) . prop ( "disabled" ) , "element is not disabled" ) ;
84
+ assert . deepEqual ( true , $ ( "#radio02" ) . prop ( "disabled" ) , "element is not disabled" ) ;
84
85
} ) ;
85
86
86
- test ( "text / showLabel options proxied" , function ( ) {
87
- expect ( 8 ) ;
87
+ QUnit . test ( "text / showLabel options proxied" , function ( assert ) {
88
+ assert . expect ( 8 ) ;
88
89
var button = $ ( "#button" ) ;
89
90
button . button ( {
90
91
text : false ,
91
92
icon : "ui-icon-gear"
92
93
} ) ;
93
- equal ( button . button ( "option" , "showLabel" ) , false ,
94
+ assert . equal ( button . button ( "option" , "showLabel" ) , false ,
94
95
"Setting the text option to false sets the showLabel option to false on init" ) ;
95
96
button . button ( "option" , "showLabel" , true ) ;
96
- equal ( button . button ( "option" , "text" ) , true ,
97
+ assert . equal ( button . button ( "option" , "text" ) , true ,
97
98
"Setting showLabel true with option method sets text option to true" ) ;
98
99
button . button ( "option" , "text" , false ) ;
99
- equal ( button . button ( "option" , "showLabel" ) , false ,
100
+ assert . equal ( button . button ( "option" , "showLabel" ) , false ,
100
101
"Setting text false with option method sets showLabel option to false" ) ;
101
102
button . button ( "option" , "text" , true ) ;
102
- equal ( button . button ( "option" , "showLabel" ) , true ,
103
+ assert . equal ( button . button ( "option" , "showLabel" ) , true ,
103
104
"Setting text true with option method sets showLabel option to true" ) ;
104
105
button . button ( "option" , "showLabel" , false ) ;
105
- equal ( button . button ( "option" , "text" ) , false ,
106
+ assert . equal ( button . button ( "option" , "text" ) , false ,
106
107
"Setting showLabel false with option method sets text option to false" ) ;
107
108
button . button ( "destroy" ) ;
108
109
button . button ( {
109
110
text : true ,
110
111
icon : "ui-icon-gear"
111
112
} ) ;
112
- equal ( button . button ( "option" , "showLabel" ) , true ,
113
+ assert . equal ( button . button ( "option" , "showLabel" ) , true ,
113
114
"Setting the text option to true sets the showLabel option to true on init" ) ;
114
115
button . button ( "destroy" ) ;
115
116
button . button ( {
116
117
showLabel : true ,
117
118
icon : "ui-icon-gear"
118
119
} ) ;
119
- equal ( button . button ( "option" , "text" ) , true ,
120
+ assert . equal ( button . button ( "option" , "text" ) , true ,
120
121
"Setting the showLabel option to true sets the text option to true on init" ) ;
121
122
button . button ( "destroy" ) ;
122
123
button . button ( {
123
124
showLabel : false ,
124
125
icon : "ui-icon-gear"
125
126
} ) ;
126
- equal ( button . button ( "option" , "text" ) , false ,
127
+ assert . equal ( button . button ( "option" , "text" ) , false ,
127
128
"Setting the showLabel option to false sets the text option to false on init" ) ;
128
129
} ) ;
129
130
130
- test ( "icon / icons options properly proxied" , function ( ) {
131
- expect ( 10 ) ;
131
+ QUnit . test ( "icon / icons options properly proxied" , function ( assert ) {
132
+ assert . expect ( 10 ) ;
132
133
133
134
var button = $ ( "#button" ) ;
134
135
135
136
button . button ( {
136
137
icon : "foo"
137
138
} ) ;
138
139
139
- equal ( button . button ( "option" , "icons.primary" ) , "foo" ,
140
+ assert . equal ( button . button ( "option" , "icons.primary" ) , "foo" ,
140
141
"Icon option properly proxied on init" ) ;
141
142
142
143
button . button ( {
143
144
icon : "bar"
144
145
} ) ;
145
146
146
- equal ( button . button ( "option" , "icons.primary" ) , "bar" ,
147
+ assert . equal ( button . button ( "option" , "icons.primary" ) , "bar" ,
147
148
"Icon option properly proxied with option method" ) ;
148
149
149
150
button . button ( {
@@ -152,9 +153,9 @@ test( "icon / icons options properly proxied", function() {
152
153
}
153
154
} ) ;
154
155
155
- equal ( button . button ( "option" , "icon" ) , "foo" ,
156
+ assert . equal ( button . button ( "option" , "icon" ) , "foo" ,
156
157
"Icons primary option properly proxied with option method" ) ;
157
- equal ( button . button ( "option" , "iconPosition" ) , "beginning" ,
158
+ assert . equal ( button . button ( "option" , "iconPosition" ) , "beginning" ,
158
159
"Icons primary option sets iconPosition option to beginning" ) ;
159
160
160
161
button . button ( {
@@ -163,9 +164,9 @@ test( "icon / icons options properly proxied", function() {
163
164
}
164
165
} ) ;
165
166
166
- equal ( button . button ( "option" , "icon" ) , "bar" ,
167
+ assert . equal ( button . button ( "option" , "icon" ) , "bar" ,
167
168
"Icons secondary option properly proxied with option method" ) ;
168
- equal ( button . button ( "option" , "iconPosition" ) , "end" ,
169
+ assert . equal ( button . button ( "option" , "iconPosition" ) , "end" ,
169
170
"Icons secondary option sets iconPosition option to end" ) ;
170
171
171
172
button . button ( "destroy" ) ;
@@ -176,9 +177,9 @@ test( "icon / icons options properly proxied", function() {
176
177
}
177
178
} ) ;
178
179
179
- equal ( button . button ( "option" , "icon" ) , "foo" ,
180
+ assert . equal ( button . button ( "option" , "icon" ) , "foo" ,
180
181
"Icons primary option properly proxied on init" ) ;
181
- equal ( button . button ( "option" , "iconPosition" ) , "beginning" ,
182
+ assert . equal ( button . button ( "option" , "iconPosition" ) , "beginning" ,
182
183
"Icons primary option sets iconPosition option to beginning on init" ) ;
183
184
184
185
button . button ( {
@@ -187,9 +188,9 @@ test( "icon / icons options properly proxied", function() {
187
188
}
188
189
} ) ;
189
190
190
- equal ( button . button ( "option" , "icon" ) , "bar" ,
191
+ assert . equal ( button . button ( "option" , "icon" ) , "bar" ,
191
192
"Icons secondary option properly proxied on init" ) ;
192
- equal ( button . button ( "option" , "iconPosition" ) , "end" ,
193
+ assert . equal ( button . button ( "option" , "iconPosition" ) , "end" ,
193
194
"Icons secondary option sets iconPosition option to end on init" ) ;
194
195
} ) ;
195
196
0 commit comments