@@ -7,13 +7,36 @@ test( "elements() order", function() {
7
7
wrap : "li"
8
8
} ) ;
9
9
10
- deepEqual ( v . elements ( ) . map ( function ( ) {
11
- return $ ( this ) . attr ( "id" ) ;
12
- } ) . get ( ) , [ "order1" , "order2" , "order3" , "order4" , "order5" , "order6" ] , "elements must be in document order" ) ;
10
+ deepEqual (
11
+ v . elements ( ) . map ( function ( ) {
12
+ return $ ( this ) . attr ( "id" ) ;
13
+ } ) . get ( ) ,
14
+ [
15
+ "order1" ,
16
+ "order2" ,
17
+ "order3" ,
18
+ "order4" ,
19
+ "order5" ,
20
+ "order6"
21
+ ] ,
22
+ "elements must be in document order"
23
+ ) ;
24
+
13
25
v . form ( ) ;
14
- deepEqual ( container . children ( ) . map ( function ( ) {
15
- return $ ( this ) . attr ( "id" ) ;
16
- } ) . get ( ) , [ "order1-error" , "order2-error" , "order3-error" , "order4-error" , "order5-error" , "order6-error" ] , "labels in error container must be in document order" ) ;
26
+ deepEqual (
27
+ container . children ( ) . map ( function ( ) {
28
+ return $ ( this ) . attr ( "id" ) ;
29
+ } ) . get ( ) ,
30
+ [
31
+ "order1-error" ,
32
+ "order2-error" ,
33
+ "order3-error" ,
34
+ "order4-error" ,
35
+ "order5-error" ,
36
+ "order6-error"
37
+ ] ,
38
+ "labels in error container must be in document order"
39
+ ) ;
17
40
} ) ;
18
41
19
42
test ( "error containers, simple" , function ( ) {
@@ -33,7 +56,21 @@ test( "error containers, simple", function() {
33
56
equal ( "" , container . find ( "h3" ) . html ( ) ) ;
34
57
35
58
v . prepareForm ( ) ;
36
- v . errorList = [ { message :"bar" , element : { name :"foo" } } , { message : "necessary" , element : { name :"required" } } ] ;
59
+ v . errorList = [
60
+ {
61
+ message : "bar" ,
62
+ element : {
63
+ name : "foo"
64
+ }
65
+ } ,
66
+ {
67
+ message : "necessary" ,
68
+ element : {
69
+ name : "required"
70
+ }
71
+ }
72
+ ] ;
73
+
37
74
ok ( ! v . valid ( ) , "form is not valid after adding errors manually" ) ;
38
75
v . showErrors ( ) ;
39
76
equal ( container . find ( ".error:not(input)" ) . length , 2 , "There should be two error labels" ) ;
@@ -68,7 +105,22 @@ test( "error containers, with labelcontainer I", function() {
68
105
equal ( 0 , labelcontainer . find ( ".error:not(input)" ) . length , "There should be no error labels in the labelcontainer" ) ;
69
106
equal ( 0 , labelcontainer . find ( "li" ) . length , "There should be no lis labels in the labelcontainer" ) ;
70
107
71
- v . errorList = [ { message :"bar" , element : { name :"foo" } } , { name : "required" , message : "necessary" , element : { name :"required" } } ] ;
108
+ v . errorList = [
109
+ {
110
+ message : "bar" ,
111
+ element : {
112
+ name : "foo"
113
+ }
114
+ } ,
115
+ {
116
+ name : "required" ,
117
+ message : "necessary" ,
118
+ element : {
119
+ name : "required"
120
+ }
121
+ }
122
+ ] ;
123
+
72
124
ok ( ! v . valid ( ) , "form is not valid after adding errors manually" ) ;
73
125
v . showErrors ( ) ;
74
126
equal ( 0 , container . find ( ".error:not(input)" ) . length , "There should be no error label in the container" ) ;
@@ -110,7 +162,12 @@ test( "errorcontainer, show/hide only on submit", function() {
110
162
ok ( container . is ( ":visible" ) , "must be visible" ) ;
111
163
112
164
$ ( "#firstname" ) . val ( "hix" ) . keyup ( ) ;
113
- $ ( "#testForm1" ) . triggerHandler ( "keyup" , [ jQuery . event . fix ( { type : "keyup" , target : $ ( "#firstname" ) [ 0 ] } ) ] ) ;
165
+ $ ( "#testForm1" ) . triggerHandler ( "keyup" , [
166
+ jQuery . event . fix ( {
167
+ type : "keyup" ,
168
+ target : $ ( "#firstname" ) [ 0 ]
169
+ } )
170
+ ] ) ;
114
171
equal ( 1 , labelContainer . find ( ".error:visible" ) . length ) ;
115
172
equal ( "There are 1 errors in your form." , container . html ( ) ) ;
116
173
@@ -122,15 +179,15 @@ test( "test label used as error container", function(assert) {
122
179
expect ( 8 ) ;
123
180
var form = $ ( "#testForm16" ) ,
124
181
field = $ ( "#testForm16text" ) ;
125
-
182
+
126
183
form . validate ( {
127
184
errorPlacement : function ( error , element ) {
128
185
// Append error within linked label
129
186
$ ( "label[for='" + element . attr ( "id" ) + "']" ) . append ( error ) ;
130
187
} ,
131
188
errorElement : "span"
132
189
} ) ;
133
-
190
+
134
191
ok ( ! field . valid ( ) ) ;
135
192
equal ( "Field Label" , field . next ( "label" ) . contents ( ":not(span)" ) . text ( ) , "container label isn't disrupted" ) ;
136
193
assert . hasError ( field , "missing" ) ;
@@ -147,11 +204,11 @@ test( "test error placed adjacent to descriptive label", function(assert) {
147
204
expect ( 8 ) ;
148
205
var form = $ ( "#testForm16" ) ,
149
206
field = $ ( "#testForm16text" ) ;
150
-
207
+
151
208
form . validate ( {
152
209
errorElement : "span"
153
210
} ) ;
154
-
211
+
155
212
ok ( ! field . valid ( ) ) ;
156
213
equal ( 1 , form . find ( "label" ) . length ) ;
157
214
equal ( "Field Label" , form . find ( "label" ) . text ( ) , "container label isn't disrupted" ) ;
@@ -168,11 +225,11 @@ test( "test descriptive label used alongside error label", function(assert) {
168
225
expect ( 8 ) ;
169
226
var form = $ ( "#testForm16" ) ,
170
227
field = $ ( "#testForm16text" ) ;
171
-
228
+
172
229
form . validate ( {
173
230
errorElement : "label"
174
231
} ) ;
175
-
232
+
176
233
ok ( ! field . valid ( ) ) ;
177
234
equal ( 1 , form . find ( "label.title" ) . length ) ;
178
235
equal ( "Field Label" , form . find ( "label.title" ) . text ( ) , "container label isn't disrupted" ) ;
@@ -189,14 +246,14 @@ test( "test custom errorElement", function(assert) {
189
246
expect ( 4 ) ;
190
247
var form = $ ( "#userForm" ) ,
191
248
field = $ ( "#username" ) ;
192
-
249
+
193
250
form . validate ( {
194
251
messages : {
195
252
username : "missing"
196
253
} ,
197
254
errorElement : "label"
198
255
} ) ;
199
-
256
+
200
257
ok ( ! field . valid ( ) ) ;
201
258
assert . hasError ( field , "missing" , "Field should have error 'missing'" ) ;
202
259
field . val ( "foo" ) ;
@@ -208,9 +265,9 @@ test( "test existing label used as error element", function(assert) {
208
265
expect ( 4 ) ;
209
266
var form = $ ( "#testForm14" ) ,
210
267
field = $ ( "#testForm14text" ) ;
211
-
212
- form . validate ( { errorElement : "label" } ) ;
213
-
268
+
269
+ form . validate ( { errorElement : "label" } ) ;
270
+
214
271
ok ( ! field . valid ( ) ) ;
215
272
assert . hasError ( field , "required" ) ;
216
273
@@ -223,9 +280,9 @@ test( "test existing non-label used as error element", function(assert) {
223
280
expect ( 4 ) ;
224
281
var form = $ ( "#testForm15" ) ,
225
282
field = $ ( "#testForm15text" ) ;
226
-
227
- form . validate ( { errorElement : "span" } ) ;
228
-
283
+
284
+ form . validate ( { errorElement : "span" } ) ;
285
+
229
286
ok ( ! field . valid ( ) ) ;
230
287
assert . hasError ( field ) ;
231
288
0 commit comments