/
produce.test.js
804 lines (702 loc) · 24.7 KB
/
produce.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
import _ from 'lodash';
import vest from '../../..';
import collector from '../../../../testUtils/collector';
import testDummy from '../../../../testUtils/testDummy';
import context from 'ctx';
import group from 'group';
import hasRemainingTests from 'hasRemainingTests';
import { setPending } from 'pending';
import produce from 'produce';
import { SEVERITY_COUNT_ERROR, SEVERITY_COUNT_WARN } from 'resultKeys';
import useTestCallbacks from 'useTestCallbacks';
import useTestObjects from 'useTestObjects';
const DRAFT_EXCLUDED_METHODS = ['done'];
const GENERATED_METHODS = [
'hasErrors',
'hasWarnings',
'getErrors',
'getWarnings',
...DRAFT_EXCLUDED_METHODS,
];
const failingFields = {};
const warningFields = {};
const SKIPPED_FIELD = 'skipped_field_name';
const groupName = 'group_name';
let state, produced, stateRef;
it.ctx = (str, cb) => it(str, () => context.run({ stateRef }, cb));
beforeEach.ctx = cb => beforeEach(() => context.run({ stateRef }, cb));
const KEPT_PROPERTIES = [
SEVERITY_COUNT_ERROR,
SEVERITY_COUNT_WARN,
'tests',
'name',
'groups',
];
let collect;
const getStateFromContext = () => {
context.run({}, ctx => {
stateRef = ctx.stateRef;
state = stateRef.current();
});
};
const runCreateSuite = suiteName =>
vest.create(suiteName, () => {
vest.skip(SKIPPED_FIELD);
collect(testDummy(vest).failing('field_1'));
collect(testDummy(vest).passing(SKIPPED_FIELD));
collect(testDummy(vest).failingWarning('field_3'));
collect(testDummy(vest).passingWarning('field_4'));
collect(testDummy(vest).failing('field_5'));
collect(testDummy(vest).failing('field_5'));
getStateFromContext();
})();
let runProduce;
describe('module: produce', () => {
let testKeys;
beforeEach(() => {
collect = collector();
runCreateSuite('suite_name');
runProduce = context.bind({ stateRef }, produce);
context.run({ stateRef }, () => {
const [testObjectsState] = useTestObjects();
testKeys = [
...new Set(testObjectsState.map(({ fieldName }) => fieldName)),
];
produced = produce();
});
collect.collection.forEach(({ fieldName, failed, isWarning }) => {
if (failed) {
failingFields[fieldName] = true;
}
if (isWarning) {
warningFields[fieldName] = true;
}
});
});
it('Should create a deep copy of subset of the state', () => {
expect(_.pick(stateRef.current(), KEPT_PROPERTIES)).isDeepCopyOf(
_.pick(produced, KEPT_PROPERTIES)
);
});
it.each(GENERATED_METHODS)(
'Should add `%s` method to the output object',
name => {
expect(typeof produced[name]).toBe('function');
}
);
describe('When draft: true', () => {
beforeEach(() => {
runCreateSuite('suiteName');
produced = runProduce(/*isDraft:*/ true);
});
it.each(DRAFT_EXCLUDED_METHODS)(
'Should produce output object without `%s` method',
name => {
expect(produced[name]).toBeUndefined();
}
);
it.each(_.difference(GENERATED_METHODS, DRAFT_EXCLUDED_METHODS))(
'Should produce output object with `%s` method',
name => {
expect(typeof produced[name]).toBe('function');
}
);
});
describe('method: getErrors', () => {
let errors;
beforeEach(() => {
errors = testKeys.filter(key =>
Boolean(!warningFields[key] && failingFields[key])
);
});
describe('When invoked with field name', () => {
it('Should return all statement messages for failed field', () => {
errors.forEach(field => {
expect(produced.getErrors(field)).toEqual(
runProduce().tests[field].errors
);
});
});
});
describe('When invoked without field name', () => {
it('Should return all statement messages', () => {
const failures = errors.reduce(
(failures, key) =>
Object.assign(failures, {
[key]: runProduce().tests[key].errors,
}),
{}
);
expect(produced.getErrors()).toEqual(failures);
});
});
});
describe('method: getWarnings', () => {
let warnings;
beforeEach(() => {
warnings = testKeys.filter(key =>
Boolean(warningFields[key] && failingFields[key])
);
});
describe('When invoked with field name', () => {
it('Should return all statement messages for failed field', () => {
warnings.forEach(field => {
expect(produced.getWarnings(field)).toEqual(
runProduce().tests[field].warnings
);
});
});
});
describe('When invoked without field name', () => {
it('Should return all statement messages', () => {
const failures = warnings.reduce(
(failures, key) =>
Object.assign(failures, {
[key]: runProduce().tests[key].warnings,
}),
{}
);
expect(produced.getWarnings()).toEqual(failures);
});
});
});
describe('method: hasErrors', () => {
describe('When invoked with field name', () => {
it('Should return the error count of the field', () => {
testKeys.forEach(key => {
expect(produced.hasErrors(key)).toBe(
!!runProduce().tests[key].errorCount
);
});
});
});
describe('When invoked without field name', () => {
it('Should return the error count of the whole suite', () => {
expect(produced.hasErrors()).toBe(!!runProduce().errorCount);
});
});
});
describe('method: hasWarnings', () => {
describe('When invoked with field name', () => {
it('Should return the warning count of the field', () => {
testKeys.forEach(key => {
expect(produced.hasWarnings(key)).toBe(
!!runProduce().tests[key].warnCount
);
});
});
});
describe('When invoked without field name', () => {
it('Should return the warn count of the whole suite', () => {
expect(produced.hasWarnings()).toBe(!!runProduce().warnCount);
});
});
});
describe('method: hasErrorsByGroup', () => {
let validate, res;
describe('When no group passed', () => {
const validation = () =>
vest.create('suite_name', () => {
group(groupName, () => {
testDummy(vest).failing();
});
});
beforeEach(() => {
validate = validation();
res = validate();
});
it('Should return false', () => {
expect(res.hasErrorsByGroup()).toBe(false);
});
it('Should return false when group does not exist', () => {
expect(res.hasErrorsByGroup('fake-group')).toBe(false);
});
});
describe('When no errors', () => {
const validation = () =>
vest.create('suite_name', () => {
testDummy(vest).passing();
testDummy(vest).failing();
testDummy(vest).failingWarning();
group(groupName, () => {
testDummy(vest).passing();
testDummy(vest).failingWarning();
});
});
beforeEach(() => {
validate = validation();
res = validate();
});
it('Should return false', () => {
expect(res.hasErrorsByGroup(groupName)).toBe(false);
});
});
describe('When errors present', () => {
const validation = () =>
vest.create('suite_name', () => {
testDummy(vest).passing();
group(groupName, () => {
testDummy(vest).failing();
});
});
beforeEach(() => {
validate = validation();
res = validate();
});
it('Should return false', () => {
expect(res.hasErrorsByGroup(groupName)).toBe(true);
});
});
describe('With fieldName', () => {
const validation = () =>
vest.create('suite_name', () => {
testDummy(vest).passing();
group(groupName, () => {
testDummy(vest).failing('failing_1');
testDummy(vest).passing('passing_1');
});
});
beforeEach(() => {
validate = validation();
res = validate();
});
it('Should return false when field is passing', () => {
expect(res.hasErrorsByGroup(groupName, 'passing_1')).toBe(false);
});
it('Should return true when field is failing', () => {
expect(res.hasErrorsByGroup(groupName, 'failing_1')).toBe(true);
});
it('Should return false when field is not present', () => {
expect(res.hasErrorsByGroup(groupName, 'I do not Exist')).toBe(false);
});
});
});
describe('method: hasWarningsByGroup', () => {
let validate, res;
describe('When no group passed', () => {
const validation = () =>
vest.create('suite_name', () => {
group(groupName, () => {
testDummy(vest).failingWarning();
});
});
beforeEach(() => {
validate = validation();
res = validate();
});
it('Should return false', () => {
expect(res.hasWarningsByGroup()).toBe(false);
});
it('Should return false when group does not exist', () => {
expect(res.hasWarningsByGroup('fake-group')).toBe(false);
});
});
describe('When no warnings', () => {
const validation = () =>
vest.create('suite_name', () => {
testDummy(vest).passing();
testDummy(vest).failing();
testDummy(vest).failingWarning();
group(groupName, () => {
testDummy(vest).passingWarning();
testDummy(vest).failing();
});
});
beforeEach(() => {
validate = validation();
res = validate();
});
it('Should return false', () => {
expect(res.hasWarningsByGroup(groupName)).toBe(false);
});
});
describe('When warnings present', () => {
const validation = () =>
vest.create('suite_name', () => {
testDummy(vest).passingWarning();
group(groupName, () => {
testDummy(vest).failingWarning();
});
});
beforeEach(() => {
validate = validation();
res = validate();
});
it('Should return true', () => {
expect(res.hasWarningsByGroup(groupName)).toBe(true);
});
});
describe('With fieldName', () => {
const validation = () =>
vest.create('suite_name', () => {
testDummy(vest).passingWarning();
group(groupName, () => {
testDummy(vest).failingWarning('failing_1');
testDummy(vest).passingWarning('passing_1');
});
});
beforeEach(() => {
validate = validation();
res = validate();
});
it('Should return false when field is passing', () => {
expect(res.hasWarningsByGroup(groupName, 'passing_1')).toBe(false);
});
it('Should return true when field is failing', () => {
expect(res.hasWarningsByGroup(groupName, 'failing_1')).toBe(true);
});
it('Should return false when field is not present', () => {
expect(res.hasWarningsByGroup(groupName, 'I do not Exist')).toBe(false);
});
});
});
describe('method: done', () => {
let doneCallback_1, doneCallback_2;
beforeEach(() => {
doneCallback_1 = jest.fn();
doneCallback_2 = jest.fn();
});
describe('When no async tests', () => {
it.ctx('Sanity', () => {
state = stateRef.current();
expect(hasRemainingTests(state)).toBe(false);
});
describe('When invoked without a field name', () => {
it('Should run callback immediately', () => {
expect(doneCallback_1).not.toHaveBeenCalled();
produced.done(doneCallback_1);
expect(doneCallback_1).toHaveBeenCalled();
expect(doneCallback_2).not.toHaveBeenCalled();
produced.done(doneCallback_2);
expect(doneCallback_2).toHaveBeenCalled();
});
it.ctx('Should pass produced result to callback', () => {
produced.done(doneCallback_1).done(doneCallback_2);
expect(doneCallback_1.mock.calls[0][0]).isDeepCopyOf(produce());
expect(doneCallback_2.mock.calls[0][0]).isDeepCopyOf(produce());
});
it.ctx('Should return produced result', () => {
expect(produced.done(doneCallback_1)).toBe(produce());
});
});
describe('When invoked with field name', () => {
it('Should run callback immediately', () => {
expect(doneCallback_1).not.toHaveBeenCalled();
produced.done('field_1', doneCallback_1);
expect(doneCallback_1).toHaveBeenCalled();
expect(doneCallback_2).not.toHaveBeenCalled();
produced.done('field_5', doneCallback_2);
expect(doneCallback_2).toHaveBeenCalled();
});
it.ctx('Should pass produced result to callback', () => {
produced.done('field_1', doneCallback_1).done(doneCallback_2);
expect(doneCallback_1.mock.calls[0][0]).isDeepCopyOf(produce());
expect(doneCallback_2.mock.calls[0][0]).isDeepCopyOf(produce());
});
it.ctx('Should return produced result', () => {
expect(produced.done('field_1', doneCallback_1)).toBe(produce());
});
describe('When field name does not exist in suite', () => {
it('Should return without calling the callback', () => {
produced.done('field_1', doneCallback_1);
produced.done('I_Do_Not_Exist', doneCallback_2);
expect(doneCallback_1).toHaveBeenCalled();
expect(doneCallback_2).not.toHaveBeenCalled();
});
});
describe('When field is skipped', () => {
it('Should return without calling the callback', () => {
produced.done('field_1', doneCallback_1);
produced.done(SKIPPED_FIELD, doneCallback_2);
expect(doneCallback_1).toHaveBeenCalled();
expect(doneCallback_2).not.toHaveBeenCalled();
});
});
});
});
describe('When async (has remaining tests)', () => {
beforeEach(() => {
context.run({ stateRef }, () => {
setPending({ fieldName: 'field_1' });
produced = produce();
});
});
it.ctx('Sanity', () => {
expect(hasRemainingTests()).toBe(true);
});
describe('When invoked without field name', () => {
it('Should return without running callback', () => {
produced.done(doneCallback_1);
expect(doneCallback_1).not.toHaveBeenCalled();
});
it('Should return produced output', () => {
expect(produced.done(doneCallback_1)).toBe(runProduce());
});
it.ctx('Should add callback to `doneCallBacks` array', () => {
const [testCallbacks] = useTestCallbacks();
return new Promise(done => {
produced.done(() => done());
// The reason we do this instead of just checking the array contents is
// that in produce().done() we wrap the callback - so we don't have
// access to it. Instead what we do here is only allow the test to
// finish if the callback runs.
testCallbacks.doneCallbacks[0]();
});
});
});
describe('When invoked with field name', () => {
const runCreateSuite = () =>
vest.create('async-suite', () => {
testDummy().failingAsync('field_1');
testDummy().passing('sync_field_2');
getStateFromContext();
})();
describe('When field is async', () => {
it.ctx(
'Should add field to fieldCallbacks and run it when the test finishes',
() =>
new Promise(done => {
const produced = runCreateSuite();
context.run({ stateRef }, () => {
const [testCallbacks] = useTestCallbacks();
expect(
testCallbacks.fieldCallbacks['field_1']
).toBeUndefined();
// The test will pass only when done gets called.
produced.done('field_1', done);
expect(
testCallbacks.fieldCallbacks['field_1']
).not.toBeUndefined();
});
})
);
});
describe('When field is sync', () => {
it.ctx('Should run callback immediately', () => {
const produced = runCreateSuite();
const [testCallbacks] = useTestCallbacks();
expect(
testCallbacks.fieldCallbacks['sync_field_2']
).toBeUndefined();
produced.done('sync_field_2', doneCallback_2);
expect(doneCallback_2).toHaveBeenCalled();
expect(
testCallbacks.fieldCallbacks['sync_field_2']
).toBeUndefined();
});
});
});
describe('When delayed', () => {
const validate = vest.create('delayed_done', () => {
testDummy(vest).failing('field_1', 'error_1:a');
testDummy(vest).failingAsync('field_2', 'error_1:b');
testDummy(vest).failingAsync('field_3', 'error_1:c', { time: 100 });
});
afterEach(() => {});
it('Should call done callback immediately when delayed', () => {
const res = validate();
return new Promise(done => {
setTimeout(() => {
const doneCb = jest.fn();
res.done(doneCb);
expect(doneCb).toHaveBeenCalled();
done();
}, 500);
});
});
});
});
});
describe('method: getErrorsByGroup', () => {
let res, validate;
const validation = () =>
vest.create('suite_name', () => {
testDummy(vest).failing('field_1');
testDummy(vest).passing('field_2');
group(groupName, () => {
testDummy(vest).failing('field_1', 'error_1:a');
testDummy(vest).failing('field_1', 'error_1:b');
testDummy(vest).failing('field_2', 'error_2');
testDummy(vest).passing('field_2');
testDummy(vest).failing('field_3', 'error_3');
testDummy(vest).failingWarning('field_1');
testDummy(vest).failingWarning('field_4');
testDummy(vest).passing('field_5');
});
});
beforeEach(() => {
validate = validation();
res = validate();
});
describe('When no group passed', () => {
it('Should throw error', () => {
expect(() => res.getErrorsByGroup()).toThrow(
'[vest]: getErrorsByGroup requires a group name. Received `undefined` instead.'
);
});
});
describe('When no field name passed', () => {
it('Should return error array by field', () => {
expect(res.getErrorsByGroup(groupName)).toEqual({
field_1: ['error_1:a', 'error_1:b'],
field_2: ['error_2'],
field_3: ['error_3'],
});
});
});
describe('When field name passed', () => {
it('Should return error array for provided field', () => {
expect(res.getErrorsByGroup(groupName, 'field_1')).toEqual([
'error_1:a',
'error_1:b',
]);
expect(res.getErrorsByGroup(groupName, 'field_2')).toEqual(['error_2']);
expect(res.getErrorsByGroup(groupName, 'field_3')).toEqual(['error_3']);
expect(res.getErrorsByGroup(groupName, 'field_4')).toEqual([]);
expect(res.getErrorsByGroup(groupName, 'field_5')).toEqual([]);
});
});
describe('When field does not exist', () => {
it('Should return an empty array', () => {
expect(res.getErrorsByGroup(groupName, 'field_100')).toEqual([]);
});
});
});
describe('method: getWarningsByGroup', () => {
let res, validate;
const validation = () =>
vest.create('suite_name', () => {
testDummy(vest).failingWarning('field_1');
testDummy(vest).passing('field_2');
group(groupName, () => {
testDummy(vest).failingWarning('field_1', 'warning_1:a');
testDummy(vest).failingWarning('field_1', 'warning_1:b');
testDummy(vest).failingWarning('field_2', 'warning_2');
testDummy(vest).passing('field_2');
testDummy(vest).failingWarning('field_3', 'warning_3');
testDummy(vest).failing('field_1');
testDummy(vest).failing('field_4');
testDummy(vest).passing('field_5');
});
});
beforeEach(() => {
validate = validation();
res = validate();
});
describe('When no group passed', () => {
it('Should throw error', () => {
expect(() => res.getWarningsByGroup()).toThrow(
'[vest]: getWarningsByGroup requires a group name. Received `undefined` instead.'
);
});
});
describe('When no field name passed', () => {
it('Should return warning array by field', () => {
expect(res.getWarningsByGroup(groupName)).toEqual({
field_1: ['warning_1:a', 'warning_1:b'],
field_2: ['warning_2'],
field_3: ['warning_3'],
});
});
});
describe('When field name passed', () => {
it('Should return warning array for provided field', () => {
expect(res.getWarningsByGroup(groupName, 'field_1')).toEqual([
'warning_1:a',
'warning_1:b',
]);
expect(res.getWarningsByGroup(groupName, 'field_2')).toEqual([
'warning_2',
]);
expect(res.getWarningsByGroup(groupName, 'field_3')).toEqual([
'warning_3',
]);
expect(res.getWarningsByGroup(groupName, 'field_4')).toEqual([]);
expect(res.getWarningsByGroup(groupName, 'field_5')).toEqual([]);
});
});
describe('When field does not exist', () => {
it('Should return an empty array', () => {
expect(res.getWarningsByGroup(groupName, 'field_100')).toEqual([]);
});
});
});
describe('produce cache (integragion)', () => {
describe('sync', () => {
const control = jest.fn();
let draft;
const validate = vest.create('cache', () => {
draft = validate.get();
getStateFromContext();
expect(draft).toBe(validate.get());
expect(produce(/*isDraft:*/ true)).toBe(validate.get());
testDummy(vest).failing();
expect(produce()).not.toBe(validate.get());
expect(draft).not.toBe(validate.get());
testDummy(vest).failing();
control();
});
it.ctx(
'Should return same result as as long as the state did not change',
() => {
let res = validate().done(result => {
expect(result).toBe(validate.get());
});
expect(control).toHaveBeenCalledTimes(1);
context.run({ stateRef }, () => {
expect(produce(/*isDraft:*/ true)).toBe(validate.get());
expect(res).not.toBe(draft);
expect(res).not.toBe(produce(/*isDraft:*/ true));
expect(draft).not.toBe(validate.get());
res = validate().done(result => {
expect(result).toBe(validate.get());
});
expect(res).not.toBe(draft);
expect(res).not.toBe(produce(/*isDraft:*/ true));
expect(control).toHaveBeenCalledTimes(2);
});
}
);
});
describe('Async', () => {
let result;
const validate = vest.create('cache-async', () => {
testDummy(vest).passing('field_1');
testDummy(vest).failing('field_2');
testDummy(vest).failingAsync('field_3');
testDummy(vest).failingAsync('field_4', { time: 250 });
});
it('Should produce correct validation result', () => {
result = validate();
const control = jest.fn();
return new Promise(done => {
expect(result.hasErrors('field_1')).toBe(false);
expect(result.hasErrors('field_2')).toBe(true);
expect(result.hasErrors('field_3')).toBe(false);
expect(result.hasErrors('field_4')).toBe(false);
result.done('field_3', res => {
expect(res).toBe(validate.get());
expect(res).not.toBe(result);
expect(res).not.isDeepCopyOf(result);
expect(res.hasErrors('field_1')).toBe(false);
expect(res.hasErrors('field_2')).toBe(true);
expect(res.hasErrors('field_3')).toBe(true);
expect(res.hasErrors('field_4')).toBe(false);
control();
});
result.done(res => {
expect(res.tests.field_4.errorCount).toBe(1);
expect(res).toBe(validate.get());
expect(res).not.toBe(result);
expect(res).not.isDeepCopyOf(result);
expect(res.hasErrors('field_1')).toBe(false);
expect(res.hasErrors('field_2')).toBe(true);
expect(res.hasErrors('field_3')).toBe(true);
expect(res.hasErrors('field_4')).toBe(true);
done();
});
});
});
});
});
});