Skip to content

Commit

Permalink
Merge pull request #339 from davisjam/honest_done
Browse files Browse the repository at this point in the history
FIX Don't call done unless the test case passes
  • Loading branch information
dmoranj authored Oct 19, 2016
2 parents a38ca63 + 3b535ba commit 53843ac
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/unit/reuse_keystone_tokens_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ describe('Reuse authentication tokens', function() {
it('both requests should finish', function(done) {
var bus = new EventEmitter();

var nRequests = 2;
var nFinishedRequests = 0;

mockOAuthApp.handler = function(req, res) {
if (req.path === currentAuthentication.authPath && req.method === 'POST') {
bus.once('secondArrived', function() {
Expand All @@ -300,7 +303,10 @@ describe('Reuse authentication tokens', function() {
bus.once('firstWaiting', function() {
request(options, function(error, response, body) {
should.not.exist(error);
done();
nFinishedRequests++;
if (nFinishedRequests === nRequests) {
done();
}
});

setTimeout(function() {
Expand All @@ -310,6 +316,10 @@ describe('Reuse authentication tokens', function() {

request(options, function(error, response, body) {
should.not.exist(error);
nFinishedRequests++;
if (nFinishedRequests === nRequests) {
done();
}
});
});
});
Expand Down

0 comments on commit 53843ac

Please sign in to comment.