Skip to content

Commit

Permalink
update test/default-messages.js to use concat-stream instead of tap.c…
Browse files Browse the repository at this point in the history
…reateConsumer() (no longer available in tap v7) #312
  • Loading branch information
nelsonic committed Sep 2, 2016
1 parent 00e595a commit eb30f50
Showing 1 changed file with 22 additions and 28 deletions.
50 changes: 22 additions & 28 deletions test/default-messages.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@
var tap = require('tap');
var path = require('path');
var spawn = require('child_process').spawn;
var trim = require('string.prototype.trim');
var concat = require('concat-stream');

tap.test('default messages', function (t) {
t.plan(1);

var tc = tap.createConsumer();
var ps = spawn(process.execPath, [path.join(__dirname, 'messages', 'defaults.js')]);

var rows = [];
tc.on('data', function (r) { rows.push(r) });
tc.on('end', function () {
var rs = rows.map(function (r) {
if (r && typeof r === 'object') {
return { id : r.id, ok : r.ok, name : trim(r.name) };
}
else return r;
});
t.same(rs, [
'TAP version 13',
'default messages',
{ id: 1, ok: true, name: 'should be truthy' },
{ id: 2, ok: true, name: 'should be falsy' },
{ id: 3, ok: true, name: 'should be equal' },
{ id: 4, ok: true, name: 'should not be equal' },
{ id: 5, ok: true, name: 'should be equivalent' },
{ id: 6, ok: true, name: 'should be equivalent' },
{ id: 7, ok: true, name: 'should be equivalent' },
'tests 7',
'pass 7',
'ok'
]);
});
ps.stdout.pipe(concat(function (rows) {

var ps = spawn(process.execPath, [ __dirname + '/messages/defaults.js' ]);
ps.stdout.pipe(tc);
t.same(rows.toString('utf8'), [
'TAP version 13',
'# default messages',
'ok 1 should be truthy',
'ok 2 should be falsy',
'ok 3 should be equal',
'ok 4 should not be equal',
'ok 5 should be equivalent',
'ok 6 should be equivalent',
'ok 7 should be equivalent',
'',
'1..7',
'# tests 7',
'# pass 7',
'',
'# ok'
].join('\n') + '\n\n');
}));
});

0 comments on commit eb30f50

Please sign in to comment.