Skip to content

Commit

Permalink
update test/nested-sync-noplan-noend.js to use concat-stream instead …
Browse files Browse the repository at this point in the history
…of tap.createConsumer (method unavailable in tap v7) for #312
  • Loading branch information
nelsonic committed Sep 2, 2016
1 parent 1bac623 commit 45ae6c1
Showing 1 changed file with 21 additions and 29 deletions.
50 changes: 21 additions & 29 deletions test/nested-sync-noplan-noend.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,41 @@
var tape = require('../');
var tap = require('tap');
var trim = require('string.prototype.trim');
var concat = require('concat-stream');

tap.test('nested sync test without plan or end', function (tt) {
tt.plan(1);

var test = tape.createHarness();
var tc = tap.createConsumer();

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;
});
var expected = [
var tc = function (rows) {
tt.same(rows.toString('utf8'), [
'TAP version 13',
'nested without plan or end',
'first',
{ id: 1, ok: true, name: 'should be truthy' },
'second',
{ id: 2, ok: true, name: 'should be truthy' },
'tests 2',
'pass 2',
'ok'
]
tt.same(rs, expected);
});
'# nested without plan or end',
'# first',
'ok 1 should be truthy',
'# second',
'ok 2 should be truthy',
'',
'1..2',
'# tests 2',
'# pass 2',
'',
'# ok'
].join('\n') + '\n');
};

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

test('nested without plan or end', function(t) {
t.test('first', function(q) {
setTimeout(function first() {
setTimeout(function first() {
q.ok(true);
q.end()
q.end()
}, 10);
});
t.test('second', function(q) {
setTimeout(function second() {
setTimeout(function second() {
q.ok(true);
q.end()
q.end()
}, 10);
});
});
Expand Down

0 comments on commit 45ae6c1

Please sign in to comment.