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