From 1897ef985b84c741ee166acfa3b4e7c61d55f668 Mon Sep 17 00:00:00 2001 From: Veikko Karsikko Date: Wed, 18 Feb 2015 22:06:00 +0200 Subject: [PATCH] Wait for async saving and removing --- .../tests/server/article.server.model.tests.js | 6 +++--- .../tests/server/article.server.routes.tests.js | 6 +++--- .../users/tests/server/user.server.model.tests.js | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/articles/tests/server/article.server.model.tests.js b/modules/articles/tests/server/article.server.model.tests.js index ee5fd067b5..b4b76b8a93 100644 --- a/modules/articles/tests/server/article.server.model.tests.js +++ b/modules/articles/tests/server/article.server.model.tests.js @@ -57,8 +57,8 @@ describe('Article Model Unit Tests:', function() { }); afterEach(function(done) { - Article.remove().exec(); - User.remove().exec(); - done(); + Article.remove().exec(function() { + User.remove().exec(done); + }); }); }); diff --git a/modules/articles/tests/server/article.server.routes.tests.js b/modules/articles/tests/server/article.server.routes.tests.js index 04874135ef..c8c35c8718 100644 --- a/modules/articles/tests/server/article.server.routes.tests.js +++ b/modules/articles/tests/server/article.server.routes.tests.js @@ -270,8 +270,8 @@ describe('Article CRUD tests', function() { }); afterEach(function(done) { - User.remove().exec(); - Article.remove().exec(); - done(); + User.remove().exec(function() { + Article.remove().exec(done); + }); }); }); diff --git a/modules/users/tests/server/user.server.model.tests.js b/modules/users/tests/server/user.server.model.tests.js index 63983d1a15..e43848764d 100644 --- a/modules/users/tests/server/user.server.model.tests.js +++ b/modules/users/tests/server/user.server.model.tests.js @@ -52,10 +52,11 @@ describe('User Model Unit Tests:', function() { }); it('should fail to save an existing user again', function(done) { - user.save(); - return user2.save(function(err) { - should.exist(err); - done(); + user.save(function() { + user2.save(function(err) { + should.exist(err); + done(); + }); }); }); @@ -69,7 +70,6 @@ describe('User Model Unit Tests:', function() { }); after(function(done) { - User.remove().exec(); - done(); + User.remove().exec(done); }); });