Skip to content

Commit

Permalink
nested tests work
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Nov 25, 2012
1 parent ddd2535 commit c9ca5be
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion example/nested.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test('nested array test', function (t) {
}
});

t.test(function (q) {
t.test('inside test', function (q) {
q.plan(2);
q.ok(true);

Expand Down
16 changes: 14 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,25 @@ function createHarness () {
else run();
});

t.on('end', function () {
t.on('test', function (st) {
pending.unshift(function () {
running = true;
out.push(st);
st.run();

st.on('end', onend);
});
});

t.on('end', onend);

function onend () {
running = false;
process.nextTick(function () {
if (pending.length) pending.shift()()
else out.close()
});
});
}
};

return out;
Expand Down
10 changes: 3 additions & 7 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ Test.prototype.test = function (name, cb) {
name = '(anonymous)';
}

/*
var t = new Test(name);
t.on('plan', function (n) {
self._plan += n;
});
*/
var t = new Test(name, { indent : self.indent + 2 });
t.run = function () { cb(t) };
self.emit('test', t);
};

Test.prototype.comment = function (msg) {
Expand Down

0 comments on commit c9ca5be

Please sign in to comment.