From dec939fde63f2b116be3d73c4c96fcccd34eef34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vesa=20Poikaj=C3=A4rvi?= Date: Mon, 2 Jan 2017 22:01:31 +0200 Subject: [PATCH] Prevent multiple done calls --- test/strategy-test.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/strategy-test.js b/test/strategy-test.js index ec9c771..ad7500f 100644 --- a/test/strategy-test.js +++ b/test/strategy-test.js @@ -383,6 +383,7 @@ describe('LDAP authentication strategy', function() { it('should return with a failure', function(cb) { var callbackCalled = false; + var testCompleted = false; var OPTS = JSON.parse(JSON.stringify(BASE_OPTS)); OPTS.server.url = 'ldap://nonexistingdomain.fi:389'; OPTS.handleErrorsAsFailures = true; @@ -398,7 +399,12 @@ describe('LDAP authentication strategy', function() { s.fail = function(msg, code) { code.should.equal(500); callbackCalled.should.be.true; - cb(); + // There can be more than one event emitted and mocha fails + // if callback is called more than once + if (testCompleted === false) { + testCompleted = true; + cb(); + } } s.error = function() {}; // Just to have this when not run via passport