-
-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update test/default-messages.js to use concat-stream instead of tap.c…
…reateConsumer() (no longer available in tap v7) #312
- Loading branch information
Showing
1 changed file
with
22 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
})); | ||
}); |