Skip to content

Commit

Permalink
update tests to match format in test/skip.js (consistency) see: https…
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Aug 28, 2016
1 parent ceec1f1 commit 3bdd82f
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 83 deletions.
7 changes: 2 additions & 5 deletions test/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ tap.test('array test', function (tt) {
var test = tape.createHarness();

test.createStream().pipe(concat(function (rows) {

var rs = rows.toString('utf8').split('\n');

tt.same(rs, [
tt.same(rows.toString('utf8'), [
'TAP version 13',
'# array',
'ok 1 should be equivalent',
Expand All @@ -27,7 +24,7 @@ tap.test('array test', function (tt) {
'',
'# ok',
''
]);
].join('\n'));
}));

test('array', function (t) {
Expand Down
6 changes: 2 additions & 4 deletions test/default-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ tap.test('default messages', function (t) {

ps.stdout.pipe(concat(function (rows) {

var rs = rows.toString('utf8').split('\n');

t.same(rs, [
t.same(rows.toString('utf8'), [
'TAP version 13',
'# default messages',
'ok 1 should be truthy',
Expand All @@ -29,6 +27,6 @@ tap.test('default messages', function (t) {
'# ok',
'',
''
]);
].join('\n'));
}));
});
43 changes: 22 additions & 21 deletions test/end-as-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,23 @@ tap.test("tape assert.end as callback", function (tt) {
var test = tape.createHarness({ exit: false })

test.createStream().pipe(concat(function (rows) {

var rs = rows.toString('utf8');

tt.equal(rs,
'TAP version 13\n'
+ '# do a task and write\n'
+ 'ok 1 null\n'
+ 'ok 2 should be equal\n'
+ '# do a task and write fail\n'
+ 'ok 3 null\n'
+ 'ok 4 should be equal\n'
+ 'not ok 5 Error: fail\n'
+ getStackTrace(rs) // tap error stack
+ '\n'
+ '1..5\n'
+ '# tests 5\n'
+ '# pass 4\n'
+ '# fail 1\n'
)
tt.equal(rows.toString('utf8'), [
'TAP version 13',
'# do a task and write',
'ok 1 null',
'ok 2 should be equal',
'# do a task and write fail',
'ok 3 null',
'ok 4 should be equal',
'not ok 5 Error: fail',
getStackTrace(rows), // tap error stack
'',
'1..5',
'# tests 5',
'# pass 4',
'# fail 1',
''
].join('\n'));
tt.end()
}));

Expand Down Expand Up @@ -70,18 +68,21 @@ function fakeAsyncWriteFail(name, cb) {
function getStackTrace(rows) {
var stacktrace = ' ---\n';
var extract = false;
rows.split('\n').forEach(function (row) {
rows.toString('utf8').split('\n').forEach(function (row) {
if (!extract) {
if (row.indexOf('---') > -1) { // start of stack trace
extract = true;
}
} else {
stacktrace += row + '\n';
if (row.indexOf('...') > -1) { // end of stack trace
extract = false;
stacktrace += ' ...';
} else {
stacktrace += row + '\n';
}

}
});
// console.log(stacktrace);
return stacktrace;
}
26 changes: 9 additions & 17 deletions test/exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ tap.test('exit ok', function (t) {
t.plan(2);

var tc = function (rows) {

var rs = rows.toString('utf8').split('\n');
t.same(rs, [
t.same(rows.toString('utf8'), [
'TAP version 13',
'# array',
'# hi',
Expand All @@ -25,7 +23,7 @@ tap.test('exit ok', function (t) {
'# ok',
'',
''
]);
].join('\n'));
}

var ps = spawn(process.execPath, [ __dirname + '/exit/ok.js' ]);
Expand All @@ -39,9 +37,7 @@ tap.test('exit fail', function (t) {
t.plan(2);

var tc = function (rows) {

var rs = rows.toString('utf8').split('\n');
t.same(rs, [
t.same(rows.toString('utf8'), [
'TAP version 13',
'# array',
'ok 1 should be equivalent',
Expand All @@ -61,7 +57,7 @@ tap.test('exit fail', function (t) {
'# fail 1',
'',
''
]);
].join('\n'));
};

var ps = spawn(process.execPath, [ __dirname + '/exit/fail.js' ]);
Expand All @@ -74,10 +70,8 @@ tap.test('exit fail', function (t) {
tap.test('too few exit', function (t) {
t.plan(2);

var tc = function (rows) {

var rs = rows.toString('utf8').split('\n');
t.same(rs, [
var tc = function (rows) {
t.same(rows.toString('utf8'), [
'TAP version 13',
'# array',
'ok 1 should be equivalent',
Expand All @@ -98,7 +92,7 @@ tap.test('too few exit', function (t) {
'# fail 1',
'',
''
]);
].join('\n'));
};

var ps = spawn(process.execPath, [ __dirname + '/exit/too_few.js' ]);
Expand All @@ -112,9 +106,7 @@ tap.test('more planned in a second test', function (t) {
t.plan(2);

var tc = function (rows) {

var rs = rows.toString('utf8').split('\n');
t.same(rs, [
t.same(rows.toString('utf8'), [
'TAP version 13',
'# first',
'ok 1 should be truthy',
Expand All @@ -133,7 +125,7 @@ tap.test('more planned in a second test', function (t) {
'# fail 1',
'',
'',
]);
].join('\n'));
};

var ps = spawn(process.execPath, [ __dirname + '/exit/second.js' ]);
Expand Down
6 changes: 2 additions & 4 deletions test/fail.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ tap.test('array test', function (tt) {

var test = tape.createHarness({ exit : false });
var tc = function (rows) {

var rs = rows.toString('utf8').split('\n');
tt.same(rs, [
tt.same(rows.toString('utf8'), [
'TAP version 13',
'# array',
'ok 1 should be equivalent',
Expand All @@ -29,7 +27,7 @@ tap.test('array test', function (tt) {
'# pass 4',
'# fail 1',
''
]);
].join('\n'));
};

test.createStream().pipe(concat(tc));
Expand Down
7 changes: 2 additions & 5 deletions test/nested-sync-noplan-noend.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ tap.test('nested sync test without plan or end', function (tt) {

var test = tape.createHarness();
var tc = function (rows) {

var rs = rows.toString('utf8').split('\n');
var expected = [
tt.same(rows.toString('utf8'), [
'TAP version 13',
'# nested without plan or end',
'# first',
Expand All @@ -23,8 +21,7 @@ tap.test('nested sync test without plan or end', function (tt) {
'',
'# ok',
''
]
tt.same(rs, expected);
].join('\n'));
};

test.createStream().pipe(concat(tc));
Expand Down
6 changes: 2 additions & 4 deletions test/nested.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ tap.test('array test', function (tt) {

var test = tape.createHarness();
var tc = function (rows) {

var rs = rows.toString('utf8').split('\n');
tt.same(rs, [
tt.same(rows.toString('utf8'), [
'TAP version 13',
'# nested array test',
'ok 1 should be equivalent',
Expand All @@ -30,7 +28,7 @@ tap.test('array test', function (tt) {
'',
'# ok',
''
]);
].join('\n'));
};

test.createStream().pipe(concat(tc));
Expand Down
6 changes: 2 additions & 4 deletions test/only.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ tap.test('tape only test', function (tt) {
var ran = [];

var tc = function (rows) {

var rs = rows.toString('utf8').split('\n');
tt.deepEqual(rs, [
tt.deepEqual(rows.toString('utf8'), [
'TAP version 13',
'# run success',
'ok 1 assert name',
Expand All @@ -20,7 +18,7 @@ tap.test('tape only test', function (tt) {
'',
'# ok',
''
])
].join('\n'));
tt.deepEqual(ran, [ 3 ]);

tt.end()
Expand Down
12 changes: 4 additions & 8 deletions test/require.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ tap.test('requiring a single module', function (t) {
t.plan(2);

var tc = function (rows) {

var rs = rows.toString('utf8').split('\n');
t.same(rs, [
t.same(rows.toString('utf8'), [
'TAP version 13',
'# module-a',
'ok 1 loaded module a',
Expand All @@ -23,7 +21,7 @@ tap.test('requiring a single module', function (t) {
'# ok',
'',
''
]);
].join('\n'));
};

var ps = tape('-r ./require/a require/test-a.js');
Expand All @@ -37,9 +35,7 @@ tap.test('requiring multiple modules', function (t) {
t.plan(2);

var tc = function (rows) {

var rs = rows.toString('utf8').split('\n');
t.same(rs, [
t.same(rows.toString('utf8'), [
'TAP version 13',
'# module-a',
'ok 1 loaded module a',
Expand All @@ -59,7 +55,7 @@ tap.test('requiring multiple modules', function (t) {
'# ok',
'',
''
]);
].join('\n'));
};

var ps = tape('-r ./require/a -r ./require/b require/test-a.js require/test-b.js');
Expand Down
6 changes: 3 additions & 3 deletions test/skip.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
var tap = require('tap');
var test = require('../');
var concat = require('concat-stream');
var ran = 0;

var concat = require('concat-stream');
var tap = require('tap');

tap.test('test SKIP comment', function (assert) {
assert.plan(1);

Expand All @@ -22,7 +23,6 @@ tap.test('test SKIP comment', function (assert) {

var tapeTest = test.createHarness();
tapeTest.createStream().pipe(concat(verify));

tapeTest('skipped', { skip: true }, function (t) {
t.end();
});
Expand Down
6 changes: 2 additions & 4 deletions test/timeoutAfter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ tap.test('timeoutAfter test', function (tt) {

var test = tape.createHarness();
var tc = function (rows) {

var rs = rows.toString('utf8').split('\n');
tt.same(rs, [
tt.same(rows.toString('utf8'), [
'TAP version 13',
'# timeoutAfter',
'not ok 1 test timed out after 1ms',
Expand All @@ -22,7 +20,7 @@ tap.test('timeoutAfter test', function (tt) {
'# pass 0',
'# fail 1',
''
]);
].join('\n'));
};

test.createStream().pipe(concat(tc));
Expand Down
6 changes: 2 additions & 4 deletions test/too_many.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ tap.test('array test', function (tt) {

var test = tape.createHarness({ exit : false });
var tc = function (rows) {

var rs = rows.toString('utf8').split('\n');
tt.same(rs, [
tt.same(rows.toString('utf8'), [
'TAP version 13',
'# array',
'ok 1 should be equivalent',
Expand All @@ -30,7 +28,7 @@ tap.test('array test', function (tt) {
'# pass 5',
'# fail 1',
''
]);
].join('\n'));
};

test.createStream().pipe(concat(tc));
Expand Down

0 comments on commit 3bdd82f

Please sign in to comment.