From 45ae6c106e7fa729ec9e5e475c12c9672c5a1324 Mon Sep 17 00:00:00 2001 From: nelsonic Date: Fri, 2 Sep 2016 19:53:08 +0100 Subject: [PATCH] update test/nested-sync-noplan-noend.js to use concat-stream instead of tap.createConsumer (method unavailable in tap v7) for #312 --- test/nested-sync-noplan-noend.js | 50 ++++++++++++++------------------ 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/test/nested-sync-noplan-noend.js b/test/nested-sync-noplan-noend.js index 15b6883a..335eef88 100644 --- a/test/nested-sync-noplan-noend.js +++ b/test/nested-sync-noplan-noend.js @@ -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); }); });