@@ -3,7 +3,7 @@ module("rules");
3
3
test ( "rules() - internal - input" , function ( ) {
4
4
var element = $ ( '#firstname' ) ;
5
5
var v = $ ( '#testForm1' ) . validate ( ) ;
6
- same ( element . rules ( ) , { required : true , minlength : 2 } ) ;
6
+ deepEqual ( element . rules ( ) , { required : true , minlength : 2 } ) ;
7
7
} ) ;
8
8
9
9
test ( "rules(), ignore method:false" , function ( ) {
@@ -13,19 +13,19 @@ test("rules(), ignore method:false", function() {
13
13
firstname : { required : false , minlength : 2 }
14
14
}
15
15
} ) ;
16
- same ( element . rules ( ) , { minlength : 2 } ) ;
16
+ deepEqual ( element . rules ( ) , { minlength : 2 } ) ;
17
17
} ) ;
18
18
19
19
test ( "rules() HTML5 required (no value)" , function ( ) {
20
20
var element = $ ( '#testForm11text1' ) ;
21
21
var v = $ ( '#testForm11' ) . validate ( ) ;
22
- same ( element . rules ( ) , { required : true } ) ;
22
+ deepEqual ( element . rules ( ) , { required : true } ) ;
23
23
} ) ;
24
24
25
25
test ( "rules() - internal - select" , function ( ) {
26
26
var element = $ ( '#meal' ) ;
27
27
var v = $ ( '#testForm3' ) . validate ( ) ;
28
- same ( element . rules ( ) , { required : true } ) ;
28
+ deepEqual ( element . rules ( ) , { required : true } ) ;
29
29
} ) ;
30
30
31
31
test ( "rules() - external" , function ( ) {
@@ -35,7 +35,7 @@ test("rules() - external", function() {
35
35
action : { date : true , min : 5 }
36
36
}
37
37
} ) ;
38
- same ( element . rules ( ) , { date : true , min : 5 } ) ;
38
+ deepEqual ( element . rules ( ) , { date : true , min : 5 } ) ;
39
39
} ) ;
40
40
41
41
test ( "rules() - external - complete form" , function ( ) {
@@ -62,7 +62,7 @@ test("rules() - external - complete form", function() {
62
62
test ( "rules() - internal - input" , function ( ) {
63
63
var element = $ ( '#form8input' ) ;
64
64
var v = $ ( '#testForm8' ) . validate ( ) ;
65
- same ( element . rules ( ) , { required : true , number : true , rangelength : [ 2 , 8 ] } ) ;
65
+ deepEqual ( element . rules ( ) , { required : true , number : true , rangelength : [ 2 , 8 ] } ) ;
66
66
} ) ;
67
67
68
68
test ( "rules(), merge min/max to range, minlength/maxlength to rangelength" , function ( ) {
@@ -79,9 +79,9 @@ test("rules(), merge min/max to range, minlength/maxlength to rangelength", func
79
79
}
80
80
}
81
81
} ) ;
82
- same ( $ ( "#firstnamec" ) . rules ( ) , { range : [ 5 , 12 ] } ) ;
82
+ deepEqual ( $ ( "#firstnamec" ) . rules ( ) , { range : [ 5 , 12 ] } ) ;
83
83
84
- same ( $ ( "#lastnamec" ) . rules ( ) , { rangelength : [ 2 , 8 ] } ) ;
84
+ deepEqual ( $ ( "#lastnamec" ) . rules ( ) , { rangelength : [ 2 , 8 ] } ) ;
85
85
jQuery . validator . autoCreateRanges = false ;
86
86
} ) ;
87
87
@@ -94,22 +94,22 @@ test("rules(), gurantee that required is at front", function() {
94
94
jQuery . each ( $ ( element ) . rules ( ) , function ( key , value ) { result . push ( key ) } ) ;
95
95
return result . join ( " " ) ;
96
96
}
97
- equals ( "required minlength" , flatRules ( "#firstname" ) ) ;
98
- equals ( "required maxlength minlength" , flatRules ( "#v2-i6" ) ) ;
99
- equals ( "required maxlength" , flatRules ( "#co_name" ) ) ;
97
+ equal ( "required minlength" , flatRules ( "#firstname" ) ) ;
98
+ equal ( "required maxlength minlength" , flatRules ( "#v2-i6" ) ) ;
99
+ equal ( "required maxlength" , flatRules ( "#co_name" ) ) ;
100
100
101
101
QUnit . reset ( ) ;
102
102
jQuery . validator . autoCreateRanges = true ;
103
103
v = $ ( "#v2" ) . validate ( ) ;
104
- equals ( "required rangelength" , flatRules ( "#v2-i6" ) ) ;
104
+ equal ( "required rangelength" , flatRules ( "#v2-i6" ) ) ;
105
105
106
106
$ ( "#subformRequired" ) . validate ( {
107
107
rules : {
108
108
co_name : "required"
109
109
}
110
110
} ) ;
111
111
$ ( "#co_name" ) . removeClass ( ) ;
112
- equals ( "required maxlength" , flatRules ( "#co_name" ) ) ;
112
+ equal ( "required maxlength" , flatRules ( "#co_name" ) ) ;
113
113
jQuery . validator . autoCreateRanges = false ;
114
114
} ) ;
115
115
@@ -119,13 +119,13 @@ test("rules(), evaluate dynamic parameters", function() {
119
119
rules : {
120
120
firstname : {
121
121
min : function ( element ) {
122
- equals ( $ ( "#firstnamec" ) [ 0 ] , element ) ;
122
+ equal ( $ ( "#firstnamec" ) [ 0 ] , element ) ;
123
123
return 12 ;
124
124
}
125
125
}
126
126
}
127
127
} ) ;
128
- same ( $ ( "#firstnamec" ) . rules ( ) , { min :12 } ) ;
128
+ deepEqual ( $ ( "#firstnamec" ) . rules ( ) , { min :12 } ) ;
129
129
} ) ;
130
130
131
131
test ( "rules(), class and attribute combinations" , function ( ) {
@@ -145,16 +145,16 @@ test("rules(), class and attribute combinations", function() {
145
145
}
146
146
}
147
147
} ) ;
148
- same ( $ ( "#v2-i1" ) . rules ( ) , { required : true } ) ;
149
- same ( $ ( "#v2-i2" ) . rules ( ) , { required : true , email : true } ) ;
150
- same ( $ ( "#v2-i3" ) . rules ( ) , { url : true } ) ;
151
- same ( $ ( "#v2-i4" ) . rules ( ) , { required : true , minlength : 2 } ) ;
152
- same ( $ ( "#v2-i5" ) . rules ( ) , { required : true , minlength : 2 , maxlength : 5 , customMethod1 : "123" } ) ;
148
+ deepEqual ( $ ( "#v2-i1" ) . rules ( ) , { required : true } ) ;
149
+ deepEqual ( $ ( "#v2-i2" ) . rules ( ) , { required : true , email : true } ) ;
150
+ deepEqual ( $ ( "#v2-i3" ) . rules ( ) , { url : true } ) ;
151
+ deepEqual ( $ ( "#v2-i4" ) . rules ( ) , { required : true , minlength : 2 } ) ;
152
+ deepEqual ( $ ( "#v2-i5" ) . rules ( ) , { required : true , minlength : 2 , maxlength : 5 , customMethod1 : "123" } ) ;
153
153
jQuery . validator . autoCreateRanges = true ;
154
- same ( $ ( "#v2-i5" ) . rules ( ) , { required : true , customMethod1 : "123" , rangelength : [ 2 , 5 ] } ) ;
155
- same ( $ ( "#v2-i6" ) . rules ( ) , { required : true , customMethod2 : true , rangelength : [ 2 , 5 ] } ) ;
154
+ deepEqual ( $ ( "#v2-i5" ) . rules ( ) , { required : true , customMethod1 : "123" , rangelength : [ 2 , 5 ] } ) ;
155
+ deepEqual ( $ ( "#v2-i6" ) . rules ( ) , { required : true , customMethod2 : true , rangelength : [ 2 , 5 ] } ) ;
156
156
jQuery . validator . autoCreateRanges = false ;
157
- same ( $ ( "#v2-i7" ) . rules ( ) , { required : true , minlength : 2 , customMethod : true } ) ;
157
+ deepEqual ( $ ( "#v2-i7" ) . rules ( ) , { required : true , minlength : 2 , customMethod : true } ) ;
158
158
159
159
delete $ . validator . methods . customMethod1 ;
160
160
delete $ . validator . messages . customMethod1 ;
@@ -185,12 +185,12 @@ test("rules(), dependency checks", function() {
185
185
} ) ;
186
186
187
187
var rules = $ ( "#firstnamec" ) . rules ( ) ;
188
- equals ( 0 , v . objectLength ( rules ) ) ;
188
+ equal ( 0 , v . objectLength ( rules ) ) ;
189
189
190
190
$ ( "#firstnamec" ) . val ( 'ab' ) ;
191
- same ( $ ( "#firstnamec" ) . rules ( ) , { min :5 } ) ;
191
+ deepEqual ( $ ( "#firstnamec" ) . rules ( ) , { min :5 } ) ;
192
192
193
- same ( $ ( "#lastnamec" ) . rules ( ) , { max :12 , email :true } ) ;
193
+ deepEqual ( $ ( "#lastnamec" ) . rules ( ) , { max :12 , email :true } ) ;
194
194
} ) ;
195
195
196
196
test ( "rules(), add and remove" , function ( ) {
@@ -199,16 +199,16 @@ test("rules(), add and remove", function() {
199
199
} , "" ) ;
200
200
$ ( "#v2" ) . validate ( ) ;
201
201
var removedAttrs = $ ( "#v2-i5" ) . removeClass ( "required" ) . removeAttrs ( "minlength maxlength" ) ;
202
- same ( $ ( "#v2-i5" ) . rules ( ) , { customMethod1 : "123" } ) ;
202
+ deepEqual ( $ ( "#v2-i5" ) . rules ( ) , { customMethod1 : "123" } ) ;
203
203
204
204
$ ( "#v2-i5" ) . addClass ( "required" ) . attr ( removedAttrs ) ;
205
- same ( $ ( "#v2-i5" ) . rules ( ) , { required : true , minlength : 2 , maxlength : 5 , customMethod1 : "123" } ) ;
205
+ deepEqual ( $ ( "#v2-i5" ) . rules ( ) , { required : true , minlength : 2 , maxlength : 5 , customMethod1 : "123" } ) ;
206
206
207
207
$ ( "#v2-i5" ) . addClass ( "email" ) . attr ( { min : 5 } ) ;
208
- same ( $ ( "#v2-i5" ) . rules ( ) , { required : true , email : true , minlength : 2 , maxlength : 5 , min : 5 , customMethod1 : "123" } ) ;
208
+ deepEqual ( $ ( "#v2-i5" ) . rules ( ) , { required : true , email : true , minlength : 2 , maxlength : 5 , min : 5 , customMethod1 : "123" } ) ;
209
209
210
210
$ ( "#v2-i5" ) . removeClass ( "required email" ) . removeAttrs ( "minlength maxlength customMethod1 min" ) ;
211
- same ( $ ( "#v2-i5" ) . rules ( ) , { } ) ;
211
+ deepEqual ( $ ( "#v2-i5" ) . rules ( ) , { } ) ;
212
212
213
213
delete $ . validator . methods . customMethod1 ;
214
214
delete $ . validator . messages . customMethod1 ;
@@ -220,35 +220,35 @@ test("rules(), add and remove static rules", function() {
220
220
firstname : "required date"
221
221
}
222
222
} ) ;
223
- same ( $ ( "#firstnamec" ) . rules ( ) , { required : true , date : true } ) ;
223
+ deepEqual ( $ ( "#firstnamec" ) . rules ( ) , { required : true , date : true } ) ;
224
224
225
225
$ ( "#firstnamec" ) . rules ( "remove" , "date" )
226
- same ( $ ( "#firstnamec" ) . rules ( ) , { required : true } ) ;
226
+ deepEqual ( $ ( "#firstnamec" ) . rules ( ) , { required : true } ) ;
227
227
$ ( "#firstnamec" ) . rules ( "add" , "email" ) ;
228
- same ( $ ( "#firstnamec" ) . rules ( ) , { required : true , email : true } ) ;
228
+ deepEqual ( $ ( "#firstnamec" ) . rules ( ) , { required : true , email : true } ) ;
229
229
230
230
$ ( "#firstnamec" ) . rules ( "remove" , "required" ) ;
231
- same ( $ ( "#firstnamec" ) . rules ( ) , { email : true } ) ;
231
+ deepEqual ( $ ( "#firstnamec" ) . rules ( ) , { email : true } ) ;
232
232
233
- same ( $ ( "#firstnamec" ) . rules ( "remove" ) , { email : true } ) ;
234
- same ( $ ( "#firstnamec" ) . rules ( ) , { } ) ;
233
+ deepEqual ( $ ( "#firstnamec" ) . rules ( "remove" ) , { email : true } ) ;
234
+ deepEqual ( $ ( "#firstnamec" ) . rules ( ) , { } ) ;
235
235
236
236
$ ( "#firstnamec" ) . rules ( "add" , "required email" ) ;
237
- same ( $ ( "#firstnamec" ) . rules ( ) , { required : true , email : true } ) ;
237
+ deepEqual ( $ ( "#firstnamec" ) . rules ( ) , { required : true , email : true } ) ;
238
238
239
239
240
- same ( $ ( "#lastnamec" ) . rules ( ) , { } ) ;
240
+ deepEqual ( $ ( "#lastnamec" ) . rules ( ) , { } ) ;
241
241
$ ( "#lastnamec" ) . rules ( "add" , "required" ) ;
242
242
$ ( "#lastnamec" ) . rules ( "add" , {
243
243
minlength : 2
244
244
} ) ;
245
- same ( $ ( "#lastnamec" ) . rules ( ) , { required : true , minlength : 2 } ) ;
245
+ deepEqual ( $ ( "#lastnamec" ) . rules ( ) , { required : true , minlength : 2 } ) ;
246
246
247
247
248
248
var removedRules = $ ( "#lastnamec" ) . rules ( "remove" , "required email" ) ;
249
- same ( $ ( "#lastnamec" ) . rules ( ) , { minlength : 2 } ) ;
249
+ deepEqual ( $ ( "#lastnamec" ) . rules ( ) , { minlength : 2 } ) ;
250
250
$ ( "#lastnamec" ) . rules ( "add" , removedRules ) ;
251
- same ( $ ( "#lastnamec" ) . rules ( ) , { required : true , minlength : 2 } ) ;
251
+ deepEqual ( $ ( "#lastnamec" ) . rules ( ) , { required : true , minlength : 2 } ) ;
252
252
} ) ;
253
253
254
254
test ( "rules(), add messages" , function ( ) {
@@ -260,7 +260,7 @@ test("rules(), add messages", function() {
260
260
} ) ;
261
261
$ ( "#testForm1clean" ) . valid ( ) ;
262
262
$ ( "#firstnamec" ) . valid ( ) ;
263
- same ( v . settings . messages . firstname , undefined ) ;
263
+ deepEqual ( v . settings . messages . firstname , undefined ) ;
264
264
265
265
$ ( "#firstnamec" ) . rules ( "add" , {
266
266
messages : {
@@ -269,5 +269,5 @@ test("rules(), add messages", function() {
269
269
} ) ;
270
270
271
271
$ ( "#firstnamec" ) . valid ( ) ;
272
- same ( v . errorList [ 0 ] && v . errorList [ 0 ] . message , "required" ) ;
272
+ deepEqual ( v . errorList [ 0 ] && v . errorList [ 0 ] . message , "required" ) ;
273
273
} ) ;
0 commit comments