Skip to content

Commit

Permalink
update test/too_many.js to use concat-stream instead of tap.createCon…
Browse files Browse the repository at this point in the history
…sumer (method unavailable in tap v7) see: #312 (comment)
  • Loading branch information
nelsonic committed Sep 2, 2016
1 parent db3a45e commit 5f89509
Showing 1 changed file with 30 additions and 33 deletions.
63 changes: 30 additions & 33 deletions test/too_many.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,59 @@
var falafel = require('falafel');
var tape = require('../');
var tap = require('tap');
var trim = require('string.prototype.trim');
var concat = require('concat-stream');

tap.test('array test', function (tt) {
tt.plan(1);

var test = tape.createHarness({ exit : false });
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;
});
tt.same(rs, [
var tc = function (rows) {
tt.same(rows.toString('utf8'), [
'TAP version 13',
'array',
{ id: 1, ok: true, name: 'should be equivalent' },
{ id: 2, ok: true, name: 'should be equivalent' },
{ id: 3, ok: true, name: 'should be equivalent' },
{ id: 4, ok: true, name: 'should be equivalent' },
{ id: 5, ok: false, name: 'plan != count' },
{ id: 6, ok: true, name: 'should be equivalent' },
'tests 6',
'pass 5',
'fail 1'
]);
});

test.createStream().pipe(tc);

'# array',
'ok 1 should be equivalent',
'ok 2 should be equivalent',
'ok 3 should be equivalent',
'ok 4 should be equivalent',
'not ok 5 plan != count',
' ---',
' operator: fail',
' expected: 3',
' actual: 4',
' ...',
'ok 6 should be equivalent',
'',
'1..6',
'# tests 6',
'# pass 5',
'# fail 1'
].join('\n') + '\n');
};

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

test('array', function (t) {
t.plan(3);

var src = '(' + function () {
var xs = [ 1, 2, [ 3, 4 ] ];
var ys = [ 5, 6 ];
g([ xs, ys ]);
} + ')()';

var output = falafel(src, function (node) {
if (node.type === 'ArrayExpression') {
node.update('fn(' + node.source() + ')');
}
});

var arrays = [
[ 3, 4 ],
[ 1, 2, [ 3, 4 ] ],
[ 5, 6 ],
[ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ],
];

Function(['fn','g'], output)(
function (xs) {
t.same(arrays.shift(), xs);
Expand Down

0 comments on commit 5f89509

Please sign in to comment.