From f6a3000a38796c191f19c82e972142e6145798bd Mon Sep 17 00:00:00 2001 From: Mihai Ene Date: Wed, 23 Mar 2016 14:06:12 +0000 Subject: [PATCH 1/3] Test for custom async validations. --- test/validations.test.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/validations.test.js b/test/validations.test.js index 082ee617..9c292a52 100644 --- a/test/validations.test.js +++ b/test/validations.test.js @@ -305,6 +305,20 @@ describe('validations', function() { describe('custom', function() { it('should validate using custom sync validation'); - it('should validate using custom async validation'); + + describe('async', function() { + it('should validate using custom async', function(done) { + User.validateAsync('countryCode', function(errCb, cb) { + setImmediate(function() { + errCb(); + }); + }); + var u = new User(getValidAttributes()); + u.isValid(function(valid) { + should.not.exist(u.errors); + valid.should.be.false; + }); + }); + }); }); }); From 1cda2b6884751fd25ceab08b023f98127400e50a Mon Sep 17 00:00:00 2001 From: Mihai Ene Date: Wed, 23 Mar 2016 14:07:36 +0000 Subject: [PATCH 2/3] Remove errors check. --- test/validations.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/validations.test.js b/test/validations.test.js index 9c292a52..e4c90a99 100644 --- a/test/validations.test.js +++ b/test/validations.test.js @@ -315,7 +315,6 @@ describe('validations', function() { }); var u = new User(getValidAttributes()); u.isValid(function(valid) { - should.not.exist(u.errors); valid.should.be.false; }); }); From 090083d42cd7586f2ef1aa716c7fecad0bf26741 Mon Sep 17 00:00:00 2001 From: Mihai Ene Date: Wed, 23 Mar 2016 14:11:17 +0000 Subject: [PATCH 3/3] Call test callback. --- test/validations.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/validations.test.js b/test/validations.test.js index e4c90a99..d48984b8 100644 --- a/test/validations.test.js +++ b/test/validations.test.js @@ -316,6 +316,7 @@ describe('validations', function() { var u = new User(getValidAttributes()); u.isValid(function(valid) { valid.should.be.false; + done(); }); }); });