Skip to content

Commit

Permalink
Prevent multiple done calls
Browse files Browse the repository at this point in the history
  • Loading branch information
vesse committed Jan 2, 2017
1 parent 5ae7f87 commit dec939f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/strategy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit dec939f

Please sign in to comment.