@@ -44,7 +44,7 @@ describe('basic validation rules', function () {
44
44
it ( 'fill correct data - no errors' , function ( ) {
45
45
46
46
//when
47
- this . Data . FirstName = "Jonh " ;
47
+ this . Data . FirstName = "John " ;
48
48
this . Data . LastName = "Smith" ;
49
49
50
50
//excercise
@@ -57,10 +57,10 @@ describe('basic validation rules', function () {
57
57
expect ( this . PersonValidator . ValidationResult . HasErrors ) . to . equal ( false ) ;
58
58
59
59
//validator properties enables to check specific rule errors
60
- expect ( this . PersonValidator . Rules [ "FirstName" ] . ValidationFailures [ "required" ] . HasError ) . to . equal ( false ) ;
61
- expect ( this . PersonValidator . Rules [ "FirstName" ] . ValidationFailures [ "maxlength" ] . HasError ) . to . equal ( false ) ;
62
- expect ( this . PersonValidator . Rules [ "LastName" ] . ValidationFailures [ "required" ] . HasError ) . to . equal ( false ) ;
63
- expect ( this . PersonValidator . Rules [ "LastName" ] . ValidationFailures [ "maxlength" ] . HasError ) . to . equal ( false ) ;
60
+ expect ( result . Errors [ "FirstName" ] . ValidationFailures [ "required" ] . HasError ) . to . equal ( false ) ;
61
+ expect ( result . Errors [ "FirstName" ] . ValidationFailures [ "maxlength" ] . HasError ) . to . equal ( false ) ;
62
+ expect ( result . Errors [ "LastName" ] . ValidationFailures [ "required" ] . HasError ) . to . equal ( false ) ;
63
+ expect ( result . Errors [ "LastName" ] . ValidationFailures [ "maxlength" ] . HasError ) . to . equal ( false ) ;
64
64
65
65
} ) ;
66
66
@@ -80,10 +80,10 @@ describe('basic validation rules', function () {
80
80
expect ( this . PersonValidator . ValidationResult . HasErrors ) . to . equal ( true ) ;
81
81
82
82
//validator properties enables to check specific rule errors
83
- expect ( this . PersonValidator . Rules [ "FirstName" ] . ValidationFailures [ "required" ] . HasError ) . to . equal ( true ) ;
84
- expect ( this . PersonValidator . Rules [ "FirstName" ] . ValidationFailures [ "maxlength" ] . HasError ) . to . equal ( false ) ;
85
- expect ( this . PersonValidator . Rules [ "LastName" ] . ValidationFailures [ "required" ] . HasError ) . to . equal ( false ) ;
86
- expect ( this . PersonValidator . Rules [ "LastName" ] . ValidationFailures [ "maxlength" ] . HasError ) . to . equal ( true ) ;
83
+ expect ( result . Errors [ "FirstName" ] . ValidationFailures [ "required" ] . HasError ) . to . equal ( true ) ;
84
+ expect ( result . Errors [ "FirstName" ] . ValidationFailures [ "maxlength" ] . HasError ) . to . equal ( false ) ;
85
+ expect ( result . Errors [ "LastName" ] . ValidationFailures [ "required" ] . HasError ) . to . equal ( false ) ;
86
+ expect ( result . Errors [ "LastName" ] . ValidationFailures [ "maxlength" ] . HasError ) . to . equal ( true ) ;
87
87
88
88
} ) ;
89
89
} ) ;
@@ -130,11 +130,14 @@ describe('basic validation rules', function () {
130
130
//excercise
131
131
var promiseResult = this . PersonValidator . ValidateAsync ( this . Data ) ;
132
132
133
- var errorInfo = this . PersonValidator . ValidationResult ;
133
+ var selfValidator = this . PersonValidator ;
134
134
promiseResult . then ( function ( response ) {
135
135
136
- //verify
137
- expect ( errorInfo . HasErrors ) . to . equal ( false ) ;
136
+ //verify by return result
137
+ expect ( response . HasErrors ) . to . equal ( false ) ;
138
+
139
+ //verify by concrete validator properties
140
+ expect ( selfValidator . ValidationResult . HasErrors ) . to . equal ( false ) ;
138
141
139
142
done ( ) ;
140
143
@@ -204,7 +207,7 @@ describe('basic validation rules', function () {
204
207
var result = this . PersonValidator . Validate ( this . Data ) ;
205
208
206
209
//verify
207
- expect ( this . PersonValidator . ValidationResult . HasErrors ) . to . equal ( false ) ;
210
+ expect ( result . HasErrors ) . to . equal ( false ) ;
208
211
209
212
} ) ;
210
213
@@ -219,7 +222,7 @@ describe('basic validation rules', function () {
219
222
var result = this . PersonValidator . Validate ( this . Data ) ;
220
223
221
224
//verify
222
- expect ( this . PersonValidator . ValidationResult . HasErrors ) . to . equal ( true ) ;
225
+ expect ( result . HasErrors ) . to . equal ( true ) ;
223
226
} ) ;
224
227
} ) ;
225
228
@@ -358,7 +361,7 @@ describe('basic validation rules', function () {
358
361
var result = this . PersonValidator . Validate ( this . Data ) ;
359
362
360
363
//verify
361
- expect ( this . PersonValidator . ValidationResult . HasErrors ) . to . equal ( false ) ;
364
+ expect ( result . HasErrors ) . to . equal ( false ) ;
362
365
363
366
} ) ;
364
367
@@ -371,7 +374,7 @@ describe('basic validation rules', function () {
371
374
var result = this . PersonValidator . Validate ( this . Data ) ;
372
375
373
376
//verify
374
- expect ( this . PersonValidator . ValidationResult . HasErrors ) . to . equal ( true ) ;
377
+ expect ( result . HasErrors ) . to . equal ( true ) ;
375
378
376
379
} ) ;
377
380
} ) ;
0 commit comments