Skip to content

Commit

Permalink
nested test at least finishes now
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Apr 29, 2013
1 parent 7951747 commit 6252fd2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ Results.prototype.push = function (t) {
t.on('test', function (st) {
subtests ++;
st.on('end', function () {
nextTick(function () {
if (--subtests === 0 && !plan) t.emit('end');
});
subtests --;
if (subtests === 0 && !plan) t.emit('end');
onend();
});
self.push(st);
});
Expand All @@ -66,13 +66,15 @@ Results.prototype.push = function (t) {
else self.fail ++
});

t.on('end', function () {
t.on('end', onend);

function onend () {
nextTick(function () {
if (subtests === 0) return;
if (subtests !== 0) return;
if (self.tests.length === 0) self.close();
else self.tests.shift().run();
});
});
}
};

Results.prototype.close = function () {
Expand Down

0 comments on commit 6252fd2

Please sign in to comment.