Skip to content
This repository was archived by the owner on Aug 30, 2021. It is now read-only.

Commit 463f5b9

Browse files
committed
fixing up a user model test which was not setup correctly without the async done() callback, which led to false postivies. Adding timeouts to the test ensures that the test completes in time, otherwise mocha's 2s timeout will fail the test
1 parent 21d87e9 commit 463f5b9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

modules/users/tests/server/user.server.model.tests.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,24 @@ describe('User Model Unit Tests:', function () {
129129
});
130130
});
131131

132-
it('should not be able to save different user with the same email address', function () {
132+
it('should not be able to save another user with the same email address', function (done) {
133+
// Test may take some time to complete due to db operations
134+
this.timeout(10000);
135+
133136
var _user = new User(user);
134137
var _user3 = new User(user3);
135138

136139
_user.remove(function (err) {
137140
should.not.exist(err);
138141
_user.save(function (err) {
139-
var user3_email = _user3.email;
142+
should.not.exist(err);
140143
_user3.email = _user.email;
141144
_user3.save(function (err) {
142145
should.exist(err);
143-
// Restoring the original email for test3 so it can be used in later tests
144-
_user3.email = user3_email;
146+
_user.remove(function(err) {
147+
should.not.exist(err);
148+
done();
149+
});
145150
});
146151
});
147152
});

0 commit comments

Comments
 (0)