@@ -34,11 +34,14 @@ describe('ValidationEngine Validate Form', () => {
3434 . then ( ( formValidationResult : FormValidationResult ) => {
3535 expect ( formValidationResult . succeeded ) . to . be . false ;
3636
37- expect ( formValidationResult . fieldErrors ) . to . have . length ( 1 ) ;
38- expect ( formValidationResult . fieldErrors [ 0 ] . succeeded ) . to . be . false ;
39- expect ( formValidationResult . fieldErrors [ 0 ] . key ) . to . be . equal ( 'fullname' ) ;
40- expect ( formValidationResult . fieldErrors [ 0 ] . type ) . to . equal ( 'REQUIRED' ) ;
41- expect ( formValidationResult . fieldErrors [ 0 ] . errorMessage ) . to . equal ( 'Mandatory field' ) ;
37+ expect ( formValidationResult . fieldErrors ) . to . deep . equal ( {
38+ fullname : {
39+ key : 'fullname' ,
40+ succeeded : false ,
41+ type : 'REQUIRED' ,
42+ errorMessage : 'Mandatory field' ,
43+ } as FieldValidationResult ,
44+ } ) ;
4245 done ( ) ;
4346 } ) ;
4447 } ) ;
@@ -73,11 +76,14 @@ describe('ValidationEngine Validate Form', () => {
7376 validationEngine . validateForm ( viewModel )
7477 . then ( ( formValidationResult : FormValidationResult ) => {
7578 expect ( formValidationResult . succeeded ) . to . be . true ;
76- expect ( formValidationResult . fieldErrors ) . to . have . length ( 1 ) ;
77- expect ( formValidationResult . fieldErrors [ 0 ] . succeeded ) . to . be . true ;
78- expect ( formValidationResult . fieldErrors [ 0 ] . key ) . to . be . equal ( 'fullname' ) ;
79- expect ( formValidationResult . fieldErrors [ 0 ] . type ) . to . equal ( 'REQUIRED' ) ;
80- expect ( formValidationResult . fieldErrors [ 0 ] . errorMessage ) . to . equal ( '' ) ;
79+ expect ( formValidationResult . fieldErrors ) . to . deep . equal ( {
80+ fullname : {
81+ key : 'fullname' ,
82+ succeeded : true ,
83+ type : 'REQUIRED' ,
84+ errorMessage : '' ,
85+ } as FieldValidationResult ,
86+ } ) ;
8187 done ( ) ;
8288 } ) ;
8389 } ) ;
@@ -155,17 +161,20 @@ describe('ValidationEngine Validate Form', () => {
155161 . then ( ( formValidationResult : FormValidationResult ) => {
156162 expect ( formValidationResult . succeeded ) . to . be . false ;
157163
158- expect ( formValidationResult . fieldErrors ) . to . have . length ( 2 ) ;
159-
160- expect ( formValidationResult . fieldErrors [ 0 ] . succeeded ) . to . be . false ;
161- expect ( formValidationResult . fieldErrors [ 0 ] . key ) . to . be . equal ( 'fullname' ) ;
162- expect ( formValidationResult . fieldErrors [ 0 ] . type ) . to . equal ( 'REQUIRED' ) ;
163- expect ( formValidationResult . fieldErrors [ 0 ] . errorMessage ) . to . equal ( 'Mandatory field' ) ;
164-
165- expect ( formValidationResult . fieldErrors [ 1 ] . succeeded ) . to . be . false ;
166- expect ( formValidationResult . fieldErrors [ 1 ] . key ) . to . be . equal ( 'password' ) ;
167- expect ( formValidationResult . fieldErrors [ 1 ] . type ) . to . equal ( 'REQUIRED' ) ;
168- expect ( formValidationResult . fieldErrors [ 1 ] . errorMessage ) . to . equal ( 'Mandatory field' ) ;
164+ expect ( formValidationResult . fieldErrors ) . to . deep . equal ( {
165+ fullname : {
166+ key : 'fullname' ,
167+ succeeded : false ,
168+ type : 'REQUIRED' ,
169+ errorMessage : 'Mandatory field' ,
170+ } as FieldValidationResult ,
171+ password : {
172+ key : 'password' ,
173+ succeeded : false ,
174+ type : 'REQUIRED' ,
175+ errorMessage : 'Mandatory field' ,
176+ } as FieldValidationResult ,
177+ } ) ;
169178
170179 done ( ) ;
171180 } ) ;
@@ -245,17 +254,20 @@ describe('ValidationEngine Validate Form', () => {
245254 . then ( ( formValidationResult : FormValidationResult ) => {
246255 expect ( formValidationResult . succeeded ) . to . be . false ;
247256
248- expect ( formValidationResult . fieldErrors ) . to . have . length ( 2 ) ;
249-
250- expect ( formValidationResult . fieldErrors [ 0 ] . succeeded ) . to . be . false ;
251- expect ( formValidationResult . fieldErrors [ 0 ] . key ) . to . be . equal ( 'fullname' ) ;
252- expect ( formValidationResult . fieldErrors [ 0 ] . type ) . to . equal ( 'REQUIRED' ) ;
253- expect ( formValidationResult . fieldErrors [ 0 ] . errorMessage ) . to . equal ( 'Mandatory field' ) ;
254-
255- expect ( formValidationResult . fieldErrors [ 1 ] . succeeded ) . to . be . false ;
256- expect ( formValidationResult . fieldErrors [ 1 ] . key ) . to . be . equal ( 'password' ) ;
257- expect ( formValidationResult . fieldErrors [ 1 ] . type ) . to . equal ( 'MINLENGTH' ) ;
258- expect ( formValidationResult . fieldErrors [ 1 ] . errorMessage ) . to . equal ( 'Password must be at least 3 characters' ) ;
257+ expect ( formValidationResult . fieldErrors ) . to . deep . equal ( {
258+ fullname : {
259+ key : 'fullname' ,
260+ succeeded : false ,
261+ type : 'REQUIRED' ,
262+ errorMessage : 'Mandatory field' ,
263+ } as FieldValidationResult ,
264+ password : {
265+ key : 'password' ,
266+ succeeded : false ,
267+ type : 'MINLENGTH' ,
268+ errorMessage : 'Password must be at least 3 characters' ,
269+ } as FieldValidationResult ,
270+ } ) ;
259271
260272 done ( ) ;
261273 } ) ;
@@ -335,17 +347,20 @@ describe('ValidationEngine Validate Form', () => {
335347 . then ( ( formValidationResult : FormValidationResult ) => {
336348 expect ( formValidationResult . succeeded ) . to . be . false ;
337349
338- expect ( formValidationResult . fieldErrors ) . to . have . length ( 2 ) ;
339-
340- expect ( formValidationResult . fieldErrors [ 0 ] . succeeded ) . to . be . false ;
341- expect ( formValidationResult . fieldErrors [ 0 ] . key ) . to . be . equal ( 'fullname' ) ;
342- expect ( formValidationResult . fieldErrors [ 0 ] . type ) . to . equal ( 'REQUIRED' ) ;
343- expect ( formValidationResult . fieldErrors [ 0 ] . errorMessage ) . to . equal ( 'Mandatory field' ) ;
344-
345- expect ( formValidationResult . fieldErrors [ 1 ] . succeeded ) . to . be . true ;
346- expect ( formValidationResult . fieldErrors [ 1 ] . key ) . to . be . equal ( 'password' ) ;
347- expect ( formValidationResult . fieldErrors [ 1 ] . type ) . to . equal ( 'MINLENGTH' ) ;
348- expect ( formValidationResult . fieldErrors [ 1 ] . errorMessage ) . to . equal ( '' ) ;
350+ expect ( formValidationResult . fieldErrors ) . to . deep . equal ( {
351+ fullname : {
352+ key : 'fullname' ,
353+ succeeded : false ,
354+ type : 'REQUIRED' ,
355+ errorMessage : 'Mandatory field' ,
356+ } as FieldValidationResult ,
357+ password : {
358+ key : 'password' ,
359+ succeeded : true ,
360+ type : 'MINLENGTH' ,
361+ errorMessage : '' ,
362+ } as FieldValidationResult ,
363+ } ) ;
349364
350365 done ( ) ;
351366 } ) ;
@@ -425,17 +440,20 @@ describe('ValidationEngine Validate Form', () => {
425440 . then ( ( formValidationResult : FormValidationResult ) => {
426441 expect ( formValidationResult . succeeded ) . to . be . true ;
427442
428- expect ( formValidationResult . fieldErrors ) . to . have . length ( 2 ) ;
429-
430- expect ( formValidationResult . fieldErrors [ 0 ] . succeeded ) . to . be . true ;
431- expect ( formValidationResult . fieldErrors [ 0 ] . key ) . to . be . equal ( 'fullname' ) ;
432- expect ( formValidationResult . fieldErrors [ 0 ] . type ) . to . equal ( 'REQUIRED' ) ;
433- expect ( formValidationResult . fieldErrors [ 0 ] . errorMessage ) . to . equal ( '' ) ;
434-
435- expect ( formValidationResult . fieldErrors [ 1 ] . succeeded ) . to . be . true ;
436- expect ( formValidationResult . fieldErrors [ 1 ] . key ) . to . be . equal ( 'password' ) ;
437- expect ( formValidationResult . fieldErrors [ 1 ] . type ) . to . equal ( 'MINLENGTH' ) ;
438- expect ( formValidationResult . fieldErrors [ 1 ] . errorMessage ) . to . equal ( '' ) ;
443+ expect ( formValidationResult . fieldErrors ) . to . deep . equal ( {
444+ fullname : {
445+ key : 'fullname' ,
446+ succeeded : true ,
447+ type : 'REQUIRED' ,
448+ errorMessage : '' ,
449+ } as FieldValidationResult ,
450+ password : {
451+ key : 'password' ,
452+ succeeded : true ,
453+ type : 'MINLENGTH' ,
454+ errorMessage : '' ,
455+ } as FieldValidationResult ,
456+ } ) ;
439457
440458 done ( ) ;
441459 } ) ;
@@ -518,12 +536,17 @@ describe('ValidationEngine Validate Form', () => {
518536 . then ( ( formValidationResult : FormValidationResult ) => {
519537 expect ( formValidationResult . succeeded ) . to . be . true ;
520538
521- expect ( formValidationResult . fieldErrors ) . to . have . length ( 1 ) ;
539+ expect ( formValidationResult . fieldErrors ) . to . deep . equal ( {
540+ fullname : {
541+ firstName : {
542+ key : 'fullname.firstName' ,
543+ succeeded : true ,
544+ type : 'REQUIRED' ,
545+ errorMessage : '' ,
546+ } as FieldValidationResult
547+ } ,
548+ } ) ;
522549
523- expect ( formValidationResult . fieldErrors [ 0 ] . succeeded ) . to . be . true ;
524- expect ( formValidationResult . fieldErrors [ 0 ] . key ) . to . be . equal ( 'fullname.firstName' ) ;
525- expect ( formValidationResult . fieldErrors [ 0 ] . type ) . to . equal ( 'REQUIRED' ) ;
526- expect ( formValidationResult . fieldErrors [ 0 ] . errorMessage ) . to . equal ( '' ) ;
527550 done ( ) ;
528551 } ) ;
529552 } ) ;
@@ -556,12 +579,17 @@ describe('ValidationEngine Validate Form', () => {
556579 . then ( ( formValidationResult : FormValidationResult ) => {
557580 expect ( formValidationResult . succeeded ) . to . be . false ;
558581
559- expect ( formValidationResult . fieldErrors ) . to . have . length ( 1 ) ;
582+ expect ( formValidationResult . fieldErrors ) . to . deep . equal ( {
583+ fullname : {
584+ firstName : {
585+ key : 'fullname.firstName' ,
586+ succeeded : false ,
587+ type : 'REQUIRED' ,
588+ errorMessage : 'Mandatory field' ,
589+ } as FieldValidationResult
590+ } ,
591+ } ) ;
560592
561- expect ( formValidationResult . fieldErrors [ 0 ] . succeeded ) . to . be . false ;
562- expect ( formValidationResult . fieldErrors [ 0 ] . key ) . to . be . equal ( 'fullname.firstName' ) ;
563- expect ( formValidationResult . fieldErrors [ 0 ] . type ) . to . equal ( 'REQUIRED' ) ;
564- expect ( formValidationResult . fieldErrors [ 0 ] . errorMessage ) . to . equal ( 'Mandatory field' ) ;
565593 done ( ) ;
566594 } ) ;
567595 } ) ;
@@ -861,11 +889,14 @@ describe('ValidationEngine Validate Form', () => {
861889 . then ( ( formValidationResult : FormValidationResult ) => {
862890 expect ( formValidationResult . succeeded ) . to . be . true ;
863891
864- expect ( formValidationResult . fieldErrors ) . to . have . length ( 1 ) ;
865- expect ( formValidationResult . fieldErrors [ 0 ] . succeeded ) . to . be . true ;
866- expect ( formValidationResult . fieldErrors [ 0 ] . key ) . to . be . equal ( 'address' ) ;
867- expect ( formValidationResult . fieldErrors [ 0 ] . type ) . to . equal ( 'REQUIRED' ) ;
868- expect ( formValidationResult . fieldErrors [ 0 ] . errorMessage ) . to . equal ( '' ) ;
892+ expect ( formValidationResult . fieldErrors ) . to . deep . equal ( {
893+ address : {
894+ key : 'address' ,
895+ succeeded : true ,
896+ type : 'REQUIRED' ,
897+ errorMessage : '' ,
898+ } as FieldValidationResult ,
899+ } ) ;
869900
870901 expect ( formValidationResult . formGlobalErrors ) . to . have . length ( 1 ) ;
871902 expect ( formValidationResult . formGlobalErrors [ 0 ] . succeeded ) . to . be . true ;
@@ -923,11 +954,14 @@ describe('ValidationEngine Validate Form', () => {
923954 . then ( ( formValidationResult : FormValidationResult ) => {
924955 expect ( formValidationResult . succeeded ) . to . be . false ;
925956
926- expect ( formValidationResult . fieldErrors ) . to . have . length ( 1 ) ;
927- expect ( formValidationResult . fieldErrors [ 0 ] . succeeded ) . to . be . false ;
928- expect ( formValidationResult . fieldErrors [ 0 ] . key ) . to . be . equal ( 'address' ) ;
929- expect ( formValidationResult . fieldErrors [ 0 ] . type ) . to . equal ( 'REQUIRED' ) ;
930- expect ( formValidationResult . fieldErrors [ 0 ] . errorMessage ) . to . equal ( 'Mandatory field' ) ;
957+ expect ( formValidationResult . fieldErrors ) . to . deep . equal ( {
958+ address : {
959+ key : 'address' ,
960+ succeeded : false ,
961+ type : 'REQUIRED' ,
962+ errorMessage : 'Mandatory field' ,
963+ } as FieldValidationResult ,
964+ } ) ;
931965
932966 expect ( formValidationResult . formGlobalErrors ) . to . have . length ( 1 ) ;
933967 expect ( formValidationResult . formGlobalErrors [ 0 ] . succeeded ) . to . be . false ;
@@ -985,11 +1019,14 @@ describe('ValidationEngine Validate Form', () => {
9851019 . then ( ( formValidationResult : FormValidationResult ) => {
9861020 expect ( formValidationResult . succeeded ) . to . be . false ;
9871021
988- expect ( formValidationResult . fieldErrors ) . to . have . length ( 1 ) ;
989- expect ( formValidationResult . fieldErrors [ 0 ] . succeeded ) . to . be . true ;
990- expect ( formValidationResult . fieldErrors [ 0 ] . key ) . to . be . equal ( 'address' ) ;
991- expect ( formValidationResult . fieldErrors [ 0 ] . type ) . to . equal ( 'REQUIRED' ) ;
992- expect ( formValidationResult . fieldErrors [ 0 ] . errorMessage ) . to . equal ( '' ) ;
1022+ expect ( formValidationResult . fieldErrors ) . to . deep . equal ( {
1023+ address : {
1024+ key : 'address' ,
1025+ succeeded : true ,
1026+ type : 'REQUIRED' ,
1027+ errorMessage : '' ,
1028+ } as FieldValidationResult ,
1029+ } ) ;
9931030
9941031 expect ( formValidationResult . formGlobalErrors ) . to . have . length ( 1 ) ;
9951032 expect ( formValidationResult . formGlobalErrors [ 0 ] . succeeded ) . to . be . false ;
@@ -1047,11 +1084,14 @@ describe('ValidationEngine Validate Form', () => {
10471084 . then ( ( formValidationResult : FormValidationResult ) => {
10481085 expect ( formValidationResult . succeeded ) . to . be . false ;
10491086
1050- expect ( formValidationResult . fieldErrors ) . to . have . length ( 1 ) ;
1051- expect ( formValidationResult . fieldErrors [ 0 ] . succeeded ) . to . be . false ;
1052- expect ( formValidationResult . fieldErrors [ 0 ] . key ) . to . be . equal ( 'address' ) ;
1053- expect ( formValidationResult . fieldErrors [ 0 ] . type ) . to . equal ( 'REQUIRED' ) ;
1054- expect ( formValidationResult . fieldErrors [ 0 ] . errorMessage ) . to . equal ( 'Mandatory field' ) ;
1087+ expect ( formValidationResult . fieldErrors ) . to . deep . equal ( {
1088+ address : {
1089+ key : 'address' ,
1090+ succeeded : false ,
1091+ type : 'REQUIRED' ,
1092+ errorMessage : 'Mandatory field' ,
1093+ } as FieldValidationResult ,
1094+ } ) ;
10551095
10561096 expect ( formValidationResult . formGlobalErrors ) . to . have . length ( 1 ) ;
10571097 expect ( formValidationResult . formGlobalErrors [ 0 ] . succeeded ) . to . be . true ;
@@ -1114,11 +1154,14 @@ describe('ValidationEngine Validate Form', () => {
11141154 . then ( ( formValidationResult : FormValidationResult ) => {
11151155 expect ( formValidationResult . succeeded ) . to . be . false ;
11161156
1117- expect ( formValidationResult . fieldErrors ) . to . have . length ( 1 ) ;
1118- expect ( formValidationResult . fieldErrors [ 0 ] . succeeded ) . to . be . false ;
1119- expect ( formValidationResult . fieldErrors [ 0 ] . key ) . to . be . equal ( 'fullname' ) ;
1120- expect ( formValidationResult . fieldErrors [ 0 ] . type ) . to . equal ( 'REQUIRED' ) ;
1121- expect ( formValidationResult . fieldErrors [ 0 ] . errorMessage ) . to . equal ( 'Mandatory field' ) ;
1157+ expect ( formValidationResult . fieldErrors ) . to . deep . equal ( {
1158+ fullname : {
1159+ key : 'fullname' ,
1160+ succeeded : false ,
1161+ type : 'REQUIRED' ,
1162+ errorMessage : 'Mandatory field' ,
1163+ } as FieldValidationResult ,
1164+ } ) ;
11221165 done ( ) ;
11231166 } ) ;
11241167 } ) ;
@@ -1154,11 +1197,14 @@ describe('ValidationEngine Validate Form', () => {
11541197 . then ( ( formValidationResult : FormValidationResult ) => {
11551198 expect ( formValidationResult . succeeded ) . to . be . true ;
11561199
1157- expect ( formValidationResult . fieldErrors ) . to . have . length ( 1 ) ;
1158- expect ( formValidationResult . fieldErrors [ 0 ] . succeeded ) . to . be . true ;
1159- expect ( formValidationResult . fieldErrors [ 0 ] . key ) . to . be . equal ( 'fullname' ) ;
1160- expect ( formValidationResult . fieldErrors [ 0 ] . type ) . to . equal ( 'REQUIRED' ) ;
1161- expect ( formValidationResult . fieldErrors [ 0 ] . errorMessage ) . to . equal ( '' ) ;
1200+ expect ( formValidationResult . fieldErrors ) . to . deep . equal ( {
1201+ fullname : {
1202+ key : 'fullname' ,
1203+ succeeded : true ,
1204+ type : 'REQUIRED' ,
1205+ errorMessage : '' ,
1206+ } as FieldValidationResult ,
1207+ } ) ;
11621208 done ( ) ;
11631209 } ) ;
11641210 } ) ;
@@ -1205,17 +1251,20 @@ describe('ValidationEngine Validate Form', () => {
12051251 . then ( ( formValidationResult : FormValidationResult ) => {
12061252 expect ( formValidationResult . succeeded ) . to . be . false ;
12071253
1208- expect ( formValidationResult . fieldErrors ) . to . have . length ( 2 ) ;
1209-
1210- expect ( formValidationResult . fieldErrors [ 0 ] . succeeded ) . to . be . false ;
1211- expect ( formValidationResult . fieldErrors [ 0 ] . key ) . to . be . equal ( 'fullname' ) ;
1212- expect ( formValidationResult . fieldErrors [ 0 ] . type ) . to . equal ( 'REQUIRED' ) ;
1213- expect ( formValidationResult . fieldErrors [ 0 ] . errorMessage ) . to . equal ( 'Mandatory field' ) ;
1214-
1215- expect ( formValidationResult . fieldErrors [ 1 ] . succeeded ) . to . be . false ;
1216- expect ( formValidationResult . fieldErrors [ 1 ] . key ) . to . be . equal ( 'password' ) ;
1217- expect ( formValidationResult . fieldErrors [ 1 ] . type ) . to . equal ( 'REQUIRED' ) ;
1218- expect ( formValidationResult . fieldErrors [ 1 ] . errorMessage ) . to . equal ( 'Mandatory field' ) ;
1254+ expect ( formValidationResult . fieldErrors ) . to . deep . equal ( {
1255+ fullname : {
1256+ key : 'fullname' ,
1257+ succeeded : false ,
1258+ type : 'REQUIRED' ,
1259+ errorMessage : 'Mandatory field' ,
1260+ } as FieldValidationResult ,
1261+ password : {
1262+ key : 'password' ,
1263+ succeeded : false ,
1264+ type : 'REQUIRED' ,
1265+ errorMessage : 'Mandatory field' ,
1266+ } as FieldValidationResult ,
1267+ } ) ;
12191268
12201269 done ( ) ;
12211270 } ) ;
@@ -1265,17 +1314,20 @@ describe('ValidationEngine Validate Form', () => {
12651314 . then ( ( formValidationResult : FormValidationResult ) => {
12661315 expect ( formValidationResult . succeeded ) . to . be . true ;
12671316
1268- expect ( formValidationResult . fieldErrors ) . to . have . length ( 2 ) ;
1269-
1270- expect ( formValidationResult . fieldErrors [ 0 ] . succeeded ) . to . be . true ;
1271- expect ( formValidationResult . fieldErrors [ 0 ] . key ) . to . be . equal ( 'fullname' ) ;
1272- expect ( formValidationResult . fieldErrors [ 0 ] . type ) . to . equal ( 'REQUIRED' ) ;
1273- expect ( formValidationResult . fieldErrors [ 0 ] . errorMessage ) . to . equal ( '' ) ;
1274-
1275- expect ( formValidationResult . fieldErrors [ 1 ] . succeeded ) . to . be . true ;
1276- expect ( formValidationResult . fieldErrors [ 1 ] . key ) . to . be . equal ( 'password' ) ;
1277- expect ( formValidationResult . fieldErrors [ 1 ] . type ) . to . equal ( 'REQUIRED' ) ;
1278- expect ( formValidationResult . fieldErrors [ 1 ] . errorMessage ) . to . equal ( '' ) ;
1317+ expect ( formValidationResult . fieldErrors ) . to . deep . equal ( {
1318+ fullname : {
1319+ key : 'fullname' ,
1320+ succeeded : true ,
1321+ type : 'REQUIRED' ,
1322+ errorMessage : '' ,
1323+ } as FieldValidationResult ,
1324+ password : {
1325+ key : 'password' ,
1326+ succeeded : true ,
1327+ type : 'REQUIRED' ,
1328+ errorMessage : '' ,
1329+ } as FieldValidationResult ,
1330+ } ) ;
12791331
12801332 done ( ) ;
12811333 } ) ;
0 commit comments