Skip to content

Commit f59defb

Browse files
committed
refactor: fix a few tests re: #5891
1 parent ccec46f commit f59defb

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

test/schema.validation.test.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,66 +377,80 @@ describe('schema', function() {
377377
likes: {type: Array, required: true}
378378
});
379379

380+
var remaining = 3;
381+
380382
Loki.path('likes').doValidate(null, function(err) {
381383
assert.ok(err instanceof ValidatorError);
384+
--remaining || done();
382385
});
383386

384387
Loki.path('likes').doValidate(undefined, function(err) {
385388
assert.ok(err instanceof ValidatorError);
389+
--remaining || done();
386390
});
387391

388392
Loki.path('likes').doValidate([], function(err) {
389393
assert.ok(err instanceof ValidatorError);
394+
--remaining || done();
390395
});
391-
done();
392396
});
393397

394398
it('boolean required', function(done) {
395399
var Animal = new Schema({
396400
isFerret: {type: Boolean, required: true}
397401
});
398402

403+
var remaining = 4;
404+
399405
Animal.path('isFerret').doValidate(null, function(err) {
400406
assert.ok(err instanceof ValidatorError);
407+
--remaining || done();
401408
});
402409

403410
Animal.path('isFerret').doValidate(undefined, function(err) {
404411
assert.ok(err instanceof ValidatorError);
412+
--remaining || done();
405413
});
406414

407415
Animal.path('isFerret').doValidate(true, function(err) {
408416
assert.ifError(err);
417+
--remaining || done();
409418
});
410419

411420
Animal.path('isFerret').doValidate(false, function(err) {
412421
assert.ifError(err);
422+
--remaining || done();
413423
});
414-
done();
415424
});
416425

417426
it('mixed required', function(done) {
418427
var Animal = new Schema({
419428
characteristics: {type: Mixed, required: true}
420429
});
421430

431+
var remaining = 4;
432+
422433
Animal.path('characteristics').doValidate(null, function(err) {
423434
assert.ok(err instanceof ValidatorError);
435+
--remaining || done();
424436
});
425437

426438
Animal.path('characteristics').doValidate(undefined, function(err) {
427439
assert.ok(err instanceof ValidatorError);
440+
--remaining || done();
428441
});
429442

430443
Animal.path('characteristics').doValidate({
431444
aggresive: true
432445
}, function(err) {
433446
assert.ifError(err);
447+
--remaining || done();
434448
});
435449

436450
Animal.path('characteristics').doValidate('none available', function(err) {
437451
assert.ifError(err);
452+
--remaining || done();
438453
});
439-
done();
440454
});
441455
});
442456

0 commit comments

Comments
 (0)