Skip to content

Commit

Permalink
remove nested test indents to pass the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Nov 25, 2012
1 parent 422bfb4 commit f6b844e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Render.prototype.begin = function () {

Render.prototype.push = function (t) {
var self = this;
this.emit('data', Array(t.indent + 1).join(' ') + '# ' + t.name + '\n');
this.emit('data', '# ' + t.name + '\n');

t.on('result', function (res) {
self.emit('data', encodeResult(res, self.count + 1));
Expand All @@ -50,7 +50,7 @@ Render.prototype.close = function () {
};

function encodeResult (res, count) {
var output = Array(res.indent + 1).join(' ');
var output = '';
output += (res.ok ? 'ok ' : 'not ok ') + count;
output += res.name ? ' ' + res.name.replace(/\s+/g, ' ') : '';

Expand All @@ -60,7 +60,7 @@ function encodeResult (res, count) {
output += '\n';

if (!res.ok) {
var outer = Array(res.indent + 3).join(' ');
var outer = ' ';
var inner = outer + ' ';
output += outer + '---\n';
output += inner + 'operator: ' + res.operator + '\n';
Expand Down
4 changes: 1 addition & 3 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ function Test (name, opts) {

this.name = name || '(anonymous)';
this.assertCount = 0;
this.indent = opts.indent || 0;
}

Test.prototype.test = function (name, cb) {
Expand All @@ -23,7 +22,7 @@ Test.prototype.test = function (name, cb) {
name = '(anonymous)';
}

var t = new Test(name, { indent : self.indent + 2 });
var t = new Test(name);
t.run = function () { cb(t) };
self.emit('test', t);
};
Expand Down Expand Up @@ -55,7 +54,6 @@ Test.prototype._assert = function assert (ok, opts) {

var res = {
id : self.assertCount ++,
indent : self.indent,
ok : Boolean(ok),
skip : defined(extra.skip, opts.skip),
name : defined(extra.message, opts.message, '(unnamed assert)'),
Expand Down
2 changes: 1 addition & 1 deletion test/nested.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ tap.test('array test', function (tt) {
{ id: 3, ok: true, name: 'should be equivalent' },
{ id: 4, ok: true, name: 'should be equivalent' },
{ id: 5, ok: true, name: 'should be equivalent' },
'# inside test',
'inside test',
{ id: 6, ok: true, name: '(unnamed assert)' },
{ id: 7, ok: true, name: '(unnamed assert)' },
'another',
Expand Down

0 comments on commit f6b844e

Please sign in to comment.