1
1
define ( [
2
+ "qunit" ,
2
3
"jquery" ,
3
4
"lib/common" ,
4
5
"ui/form" ,
5
6
"ui/labels" ,
6
7
"ui/unique-id"
7
- ] , function ( $ , common ) {
8
+ ] , function ( QUnit , $ , common ) {
8
9
9
- module ( "core - jQuery extensions" ) ;
10
+ QUnit . module ( "core - jQuery extensions" ) ;
10
11
11
12
common . testJshint ( "core" ) ;
12
13
13
- test ( "innerWidth - getter" , function ( ) {
14
- expect ( 2 ) ;
14
+ QUnit . test ( "innerWidth - getter" , function ( assert ) {
15
+ assert . expect ( 2 ) ;
15
16
var el = $ ( "#dimensions" ) ;
16
17
17
- equal ( el . innerWidth ( ) , 122 , "getter passthru" ) ;
18
+ assert . equal ( el . innerWidth ( ) , 122 , "getter passthru" ) ;
18
19
el . hide ( ) ;
19
- equal ( el . innerWidth ( ) , 122 , "getter passthru when hidden" ) ;
20
+ assert . equal ( el . innerWidth ( ) , 122 , "getter passthru when hidden" ) ;
20
21
} ) ;
21
22
22
- test ( "innerWidth - setter" , function ( ) {
23
- expect ( 2 ) ;
23
+ QUnit . test ( "innerWidth - setter" , function ( assert ) {
24
+ assert . expect ( 2 ) ;
24
25
var el = $ ( "#dimensions" ) ;
25
26
26
27
el . innerWidth ( 120 ) ;
27
- equal ( el . width ( ) , 98 , "width set properly" ) ;
28
+ assert . equal ( el . width ( ) , 98 , "width set properly" ) ;
28
29
el . hide ( ) ;
29
30
el . innerWidth ( 100 ) ;
30
- equal ( el . width ( ) , 78 , "width set properly when hidden" ) ;
31
+ assert . equal ( el . width ( ) , 78 , "width set properly when hidden" ) ;
31
32
} ) ;
32
33
33
- test ( "innerHeight - getter" , function ( ) {
34
- expect ( 2 ) ;
34
+ QUnit . test ( "innerHeight - getter" , function ( assert ) {
35
+ assert . expect ( 2 ) ;
35
36
var el = $ ( "#dimensions" ) ;
36
37
37
- equal ( el . innerHeight ( ) , 70 , "getter passthru" ) ;
38
+ assert . equal ( el . innerHeight ( ) , 70 , "getter passthru" ) ;
38
39
el . hide ( ) ;
39
- equal ( el . innerHeight ( ) , 70 , "getter passthru when hidden" ) ;
40
+ assert . equal ( el . innerHeight ( ) , 70 , "getter passthru when hidden" ) ;
40
41
} ) ;
41
42
42
- test ( "innerHeight - setter" , function ( ) {
43
- expect ( 2 ) ;
43
+ QUnit . test ( "innerHeight - setter" , function ( assert ) {
44
+ assert . expect ( 2 ) ;
44
45
var el = $ ( "#dimensions" ) ;
45
46
46
47
el . innerHeight ( 60 ) ;
47
- equal ( el . height ( ) , 40 , "height set properly" ) ;
48
+ assert . equal ( el . height ( ) , 40 , "height set properly" ) ;
48
49
el . hide ( ) ;
49
50
el . innerHeight ( 50 ) ;
50
- equal ( el . height ( ) , 30 , "height set properly when hidden" ) ;
51
+ assert . equal ( el . height ( ) , 30 , "height set properly when hidden" ) ;
51
52
} ) ;
52
53
53
- test ( "outerWidth - getter" , function ( ) {
54
- expect ( 2 ) ;
54
+ QUnit . test ( "outerWidth - getter" , function ( assert ) {
55
+ assert . expect ( 2 ) ;
55
56
var el = $ ( "#dimensions" ) ;
56
57
57
- equal ( el . outerWidth ( ) , 140 , "getter passthru" ) ;
58
+ assert . equal ( el . outerWidth ( ) , 140 , "getter passthru" ) ;
58
59
el . hide ( ) ;
59
- equal ( el . outerWidth ( ) , 140 , "getter passthru when hidden" ) ;
60
+ assert . equal ( el . outerWidth ( ) , 140 , "getter passthru when hidden" ) ;
60
61
} ) ;
61
62
62
- test ( "outerWidth - setter" , function ( ) {
63
- expect ( 2 ) ;
63
+ QUnit . test ( "outerWidth - setter" , function ( assert ) {
64
+ assert . expect ( 2 ) ;
64
65
var el = $ ( "#dimensions" ) ;
65
66
66
67
el . outerWidth ( 130 ) ;
67
- equal ( el . width ( ) , 90 , "width set properly" ) ;
68
+ assert . equal ( el . width ( ) , 90 , "width set properly" ) ;
68
69
el . hide ( ) ;
69
70
el . outerWidth ( 120 ) ;
70
- equal ( el . width ( ) , 80 , "width set properly when hidden" ) ;
71
+ assert . equal ( el . width ( ) , 80 , "width set properly when hidden" ) ;
71
72
} ) ;
72
73
73
- test ( "outerWidth(true) - getter" , function ( ) {
74
- expect ( 2 ) ;
74
+ QUnit . test ( "outerWidth(true) - getter" , function ( assert ) {
75
+ assert . expect ( 2 ) ;
75
76
var el = $ ( "#dimensions" ) ;
76
77
77
- equal ( el . outerWidth ( true ) , 154 , "getter passthru w/ margin" ) ;
78
+ assert . equal ( el . outerWidth ( true ) , 154 , "getter passthru w/ margin" ) ;
78
79
el . hide ( ) ;
79
- equal ( el . outerWidth ( true ) , 154 , "getter passthru w/ margin when hidden" ) ;
80
+ assert . equal ( el . outerWidth ( true ) , 154 , "getter passthru w/ margin when hidden" ) ;
80
81
} ) ;
81
82
82
- test ( "outerWidth(true) - setter" , function ( ) {
83
- expect ( 2 ) ;
83
+ QUnit . test ( "outerWidth(true) - setter" , function ( assert ) {
84
+ assert . expect ( 2 ) ;
84
85
var el = $ ( "#dimensions" ) ;
85
86
86
87
el . outerWidth ( 130 , true ) ;
87
- equal ( el . width ( ) , 76 , "width set properly" ) ;
88
+ assert . equal ( el . width ( ) , 76 , "width set properly" ) ;
88
89
el . hide ( ) ;
89
90
el . outerWidth ( 120 , true ) ;
90
- equal ( el . width ( ) , 66 , "width set properly when hidden" ) ;
91
+ assert . equal ( el . width ( ) , 66 , "width set properly when hidden" ) ;
91
92
} ) ;
92
93
93
- test ( "outerHeight - getter" , function ( ) {
94
- expect ( 2 ) ;
94
+ QUnit . test ( "outerHeight - getter" , function ( assert ) {
95
+ assert . expect ( 2 ) ;
95
96
var el = $ ( "#dimensions" ) ;
96
97
97
- equal ( el . outerHeight ( ) , 86 , "getter passthru" ) ;
98
+ assert . equal ( el . outerHeight ( ) , 86 , "getter passthru" ) ;
98
99
el . hide ( ) ;
99
- equal ( el . outerHeight ( ) , 86 , "getter passthru when hidden" ) ;
100
+ assert . equal ( el . outerHeight ( ) , 86 , "getter passthru when hidden" ) ;
100
101
} ) ;
101
102
102
- test ( "outerHeight - setter" , function ( ) {
103
- expect ( 2 ) ;
103
+ QUnit . test ( "outerHeight - setter" , function ( assert ) {
104
+ assert . expect ( 2 ) ;
104
105
var el = $ ( "#dimensions" ) ;
105
106
106
107
el . outerHeight ( 80 ) ;
107
- equal ( el . height ( ) , 44 , "height set properly" ) ;
108
+ assert . equal ( el . height ( ) , 44 , "height set properly" ) ;
108
109
el . hide ( ) ;
109
110
el . outerHeight ( 70 ) ;
110
- equal ( el . height ( ) , 34 , "height set properly when hidden" ) ;
111
+ assert . equal ( el . height ( ) , 34 , "height set properly when hidden" ) ;
111
112
} ) ;
112
113
113
- test ( "outerHeight(true) - getter" , function ( ) {
114
- expect ( 2 ) ;
114
+ QUnit . test ( "outerHeight(true) - getter" , function ( assert ) {
115
+ assert . expect ( 2 ) ;
115
116
var el = $ ( "#dimensions" ) ;
116
117
117
- equal ( el . outerHeight ( true ) , 98 , "getter passthru w/ margin" ) ;
118
+ assert . equal ( el . outerHeight ( true ) , 98 , "getter passthru w/ margin" ) ;
118
119
el . hide ( ) ;
119
- equal ( el . outerHeight ( true ) , 98 , "getter passthru w/ margin when hidden" ) ;
120
+ assert . equal ( el . outerHeight ( true ) , 98 , "getter passthru w/ margin when hidden" ) ;
120
121
} ) ;
121
122
122
- test ( "outerHeight(true) - setter" , function ( ) {
123
- expect ( 2 ) ;
123
+ QUnit . test ( "outerHeight(true) - setter" , function ( assert ) {
124
+ assert . expect ( 2 ) ;
124
125
var el = $ ( "#dimensions" ) ;
125
126
126
127
el . outerHeight ( 90 , true ) ;
127
- equal ( el . height ( ) , 42 , "height set properly" ) ;
128
+ assert . equal ( el . height ( ) , 42 , "height set properly" ) ;
128
129
el . hide ( ) ;
129
130
el . outerHeight ( 80 , true ) ;
130
- equal ( el . height ( ) , 32 , "height set properly when hidden" ) ;
131
+ assert . equal ( el . height ( ) , 32 , "height set properly when hidden" ) ;
131
132
} ) ;
132
133
133
- test ( "uniqueId / removeUniqueId" , function ( ) {
134
- expect ( 3 ) ;
134
+ QUnit . test ( "uniqueId / removeUniqueId" , function ( assert ) {
135
+ assert . expect ( 3 ) ;
135
136
var el = $ ( "img" ) . eq ( 0 ) ;
136
- equal ( el . attr ( "id" ) , null , "element has no initial id" ) ;
137
+ assert . equal ( el . attr ( "id" ) , null , "element has no initial id" ) ;
137
138
el . uniqueId ( ) ;
138
- ok ( / u i - i d - \d + $ / . test ( el . attr ( "id" ) ) , "element has generated id" ) ;
139
+ assert . ok ( / u i - i d - \d + $ / . test ( el . attr ( "id" ) ) , "element has generated id" ) ;
139
140
el . removeUniqueId ( ) ;
140
- equal ( el . attr ( "id" ) , null , "unique id has been removed from element" ) ;
141
+ assert . equal ( el . attr ( "id" ) , null , "unique id has been removed from element" ) ;
141
142
} ) ;
142
143
143
- test ( "Labels" , function ( ) {
144
- expect ( 2 ) ;
144
+ QUnit . test ( "Labels" , function ( assert ) {
145
+ assert . expect ( 2 ) ;
145
146
146
147
var expected = [ "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "10" ] ;
147
148
var dom = $ ( "#labels-fragment" ) ;
@@ -155,7 +156,7 @@ test( "Labels", function() {
155
156
return $ . trim ( $ ( this ) . text ( ) ) ;
156
157
} ) . get ( ) ;
157
158
158
- deepEqual ( found , expected ,
159
+ assert . deepEqual ( found , expected ,
159
160
".labels() finds all labels in " + testType + ", and sorts them in DOM order" ) ;
160
161
}
161
162
@@ -176,8 +177,9 @@ test( "Labels", function() {
176
177
inputs . each ( function ( ) {
177
178
var input = $ ( this ) ;
178
179
179
- asyncTest ( name + this . id . replace ( / _ / g, " " ) , function ( ) {
180
- expect ( 1 ) ;
180
+ QUnit . test ( name + this . id . replace ( / _ / g, " " ) , function ( assert ) {
181
+ var ready = assert . async ( ) ;
182
+ assert . expect ( 1 ) ;
181
183
var form = input . form ( ) ;
182
184
183
185
// If input has a form the value should reset to "" if not it should be "changed"
@@ -193,8 +195,8 @@ test( "Labels", function() {
193
195
} ) ;
194
196
195
197
setTimeout ( function ( ) {
196
- equal ( input . val ( ) , value , "Proper form found for #" + input . attr ( "id" ) ) ;
197
- start ( ) ;
198
+ assert . equal ( input . val ( ) , value , "Proper form found for #" + input . attr ( "id" ) ) ;
199
+ ready ( ) ;
198
200
} ) ;
199
201
} ) ;
200
202
} ) ;
0 commit comments