|
1 | 1 | var tape = require('../');
|
2 | 2 | var tap = require('tap');
|
3 |
| -var trim = require('string.prototype.trim'); |
| 3 | +var concat = require('concat-stream'); |
4 | 4 |
|
5 | 5 | tap.test('nested sync test without plan or end', function (tt) {
|
6 | 6 | tt.plan(1);
|
7 | 7 |
|
8 | 8 | var test = tape.createHarness();
|
9 |
| - var tc = tap.createConsumer(); |
| 9 | + var tc = function (rows) { |
10 | 10 |
|
11 |
| - var rows = []; |
12 |
| - tc.on('data', function (r) { rows.push(r) }); |
13 |
| - tc.on('end', function () { |
14 |
| - var rs = rows.map(function (r) { |
15 |
| - if (r && typeof r === 'object') { |
16 |
| - return { id : r.id, ok : r.ok, name : trim(r.name) }; |
17 |
| - } |
18 |
| - else return r; |
19 |
| - }); |
| 11 | + var rs = rows.toString('utf8').split('\n'); |
20 | 12 | var expected = [
|
21 | 13 | 'TAP version 13',
|
22 |
| - 'nested without plan or end', |
23 |
| - 'first', |
24 |
| - { id: 1, ok: true, name: 'should be truthy' }, |
25 |
| - 'second', |
26 |
| - { id: 2, ok: true, name: 'should be truthy' }, |
27 |
| - 'tests 2', |
28 |
| - 'pass 2', |
29 |
| - 'ok' |
| 14 | + '# nested without plan or end', |
| 15 | + '# first', |
| 16 | + 'ok 1 should be truthy', |
| 17 | + '# second', |
| 18 | + 'ok 2 should be truthy', |
| 19 | + '', |
| 20 | + '1..2', |
| 21 | + '# tests 2', |
| 22 | + '# pass 2', |
| 23 | + '', |
| 24 | + '# ok', |
| 25 | + '' |
30 | 26 | ]
|
31 | 27 | tt.same(rs, expected);
|
32 |
| - }); |
| 28 | + }; |
33 | 29 |
|
34 |
| - test.createStream().pipe(tc); |
| 30 | + test.createStream().pipe(concat(tc)); |
35 | 31 |
|
36 | 32 | test('nested without plan or end', function(t) {
|
37 | 33 | t.test('first', function(q) {
|
|
0 commit comments