1
1
define ( [
2
+ "qunit" ,
2
3
"jquery" ,
3
4
"ui/widgets/checkboxradio"
4
- ] , function ( $ ) {
5
+ ] , function ( QUnit , $ ) {
5
6
6
- module ( "Checkboxradio: core" ) ;
7
+ QUnit . module ( "Checkboxradio: core" ) ;
7
8
8
- test ( "Checkbox - Initial class structure" , function ( assert ) {
9
- expect ( 2 ) ;
9
+ QUnit . test ( "Checkbox - Initial class structure" , function ( assert ) {
10
+ assert . expect ( 2 ) ;
10
11
var input = $ ( "#check" ) ,
11
12
label = $ ( "label[for=check]" ) ;
12
13
@@ -15,8 +16,8 @@ test( "Checkbox - Initial class structure", function( assert ) {
15
16
assert . hasClasses ( label , "ui-button ui-widget ui-checkboxradio-label ui-corner-all" ) ;
16
17
} ) ;
17
18
18
- test ( "Radios - Initial class structure" , function ( assert ) {
19
- expect ( 6 ) ;
19
+ QUnit . test ( "Radios - Initial class structure" , function ( assert ) {
20
+ assert . expect ( 6 ) ;
20
21
var inputs = $ ( "#radio0 input" ) ,
21
22
labels = $ ( "#radio0 label" ) ;
22
23
@@ -29,12 +30,13 @@ test( "Radios - Initial class structure", function( assert ) {
29
30
} ) ;
30
31
} ) ;
31
32
32
- asyncTest ( "Ensure checked after single click on checkbox label button" , function ( assert ) {
33
- expect ( 2 ) ;
33
+ QUnit . test ( "Ensure checked after single click on checkbox label button" , function ( assert ) {
34
+ var ready = assert . async ( ) ;
35
+ assert . expect ( 2 ) ;
34
36
35
37
$ ( "#check2" ) . checkboxradio ( ) . change ( function ( ) {
36
38
var label = $ ( this ) . checkboxradio ( "widget" ) ;
37
- ok ( this . checked , "checked ok" ) ;
39
+ assert . ok ( this . checked , "checked ok" ) ;
38
40
39
41
assert . hasClasses ( label , "ui-state-active" ) ;
40
42
} ) ;
@@ -45,21 +47,21 @@ asyncTest( "Ensure checked after single click on checkbox label button", functio
45
47
// tracked down, this delay will have to do.
46
48
setTimeout ( function ( ) {
47
49
$ ( "#check2" ) . checkboxradio ( "widget" ) . simulate ( "click" ) ;
48
- start ( ) ;
50
+ ready ( ) ;
49
51
} ) ;
50
52
} ) ;
51
53
52
- test ( "Handle form association via form attribute" , function ( assert ) {
53
- expect ( 4 ) ;
54
+ QUnit . test ( "Handle form association via form attribute" , function ( assert ) {
55
+ assert . expect ( 4 ) ;
54
56
55
57
var radio1 = $ ( "#crazy-form-1" ) . checkboxradio ( ) ;
56
58
var radio1Label = radio1 . checkboxradio ( "widget" ) ;
57
59
var radio2 = $ ( "#crazy-form-2" ) . checkboxradio ( ) ;
58
60
var radio2Label = radio2 . checkboxradio ( "widget" ) ;
59
61
60
62
radio2 . change ( function ( ) {
61
- ok ( this . checked , "#2 checked" ) ;
62
- ok ( ! radio1 [ 0 ] . checked , "#1 not checked" ) ;
63
+ assert . ok ( this . checked , "#2 checked" ) ;
64
+ assert . ok ( ! radio1 [ 0 ] . checked , "#1 not checked" ) ;
63
65
64
66
assert . hasClasses ( radio2Label , "ui-state-active" ) ;
65
67
assert . lacksClasses ( radio1Label , "ui-state-active" ) ;
@@ -68,8 +70,8 @@ test( "Handle form association via form attribute", function( assert ) {
68
70
radio2Label . simulate ( "click" ) ;
69
71
} ) ;
70
72
71
- test ( "Checkbox creation requires a label, and finds it in all cases" , function ( assert ) {
72
- expect ( 7 ) ;
73
+ QUnit . test ( "Checkbox creation requires a label, and finds it in all cases" , function ( assert ) {
74
+ assert . expect ( 7 ) ;
73
75
var groups = [
74
76
"<span><label for='t7092a'></label><input type='checkbox' id='t7092a'></span>" ,
75
77
"<span><input type='checkbox' id='t7092b'><label for='t7092b'></label></span>" ,
@@ -88,8 +90,8 @@ test( "Checkbox creation requires a label, and finds it in all cases", function(
88
90
} ) ;
89
91
} ) ;
90
92
91
- test ( "Calling checkboxradio on an unsupported element throws an error" , function ( assert ) {
92
- expect ( 2 ) ;
93
+ QUnit . test ( "Calling checkboxradio on an unsupported element throws an error" , function ( assert ) {
94
+ assert . expect ( 2 ) ;
93
95
94
96
var errorMessage =
95
97
"Can't create checkboxradio on element.nodeName=div and element.type=undefined" ;
@@ -117,8 +119,8 @@ test( "Calling checkboxradio on an unsupported element throws an error", functio
117
119
) ;
118
120
} ) ;
119
121
120
- test ( "Calling checkboxradio on an input with no label throws an error" , function ( assert ) {
121
- expect ( 1 ) ;
122
+ QUnit . test ( "Calling checkboxradio on an input with no label throws an error" , function ( assert ) {
123
+ assert . expect ( 1 ) ;
122
124
123
125
var errorMessage = "No label found for checkboxradio widget" ;
124
126
var error = new Error ( errorMessage ) ;
0 commit comments