|
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: 'should be equivalent' }, |
29 |
| - 'tests 5', |
30 |
| - 'pass 4', |
31 |
| - '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 should be equivalent', |
| 21 | + ' ---', |
| 22 | + ' operator: deepEqual', |
| 23 | + ' expected: [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]', |
| 24 | + ' actual: [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]', |
| 25 | + ' ...', |
| 26 | + '', |
| 27 | + '1..5', |
| 28 | + '# tests 5', |
| 29 | + '# pass 4', |
| 30 | + '# fail 1', |
| 31 | + '' |
32 | 32 | ]);
|
33 |
| - }); |
| 33 | + }; |
34 | 34 |
|
35 |
| - test.createStream().pipe(tc); |
| 35 | + test.createStream().pipe(concat(tc)); |
36 | 36 |
|
37 | 37 | test('array', function (t) {
|
38 | 38 | t.plan(5);
|
|
0 commit comments