[Pkg-javascript-commits] [node-stream-splicer] 07/71: test for push halfway through
Bastien Roucariès
rouca at moszumanska.debian.org
Fri Dec 15 09:55:46 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-stream-splicer.
commit 948e292e11b430c80247995a182913eea42cfc1f
Author: James Halliday <mail at substack.net>
Date: Sun Jun 8 05:07:33 2014 -0700
test for push halfway through
---
test/push.js | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/test/push.js b/test/push.js
new file mode 100644
index 0000000..245be30
--- /dev/null
+++ b/test/push.js
@@ -0,0 +1,54 @@
+var pipeline = require('../');
+var through = require('through2');
+var split = require('split');
+var concat = require('concat-stream');
+var test = require('tape');
+
+test('push to different destinations', function (t) {
+ var expected = {};
+ expected.first = [ 333, 444, 555, 666, 777 ];
+ expected.second = [ 6.66, 7.77 ];
+ expected.output = [ 3.33, 4.44, 5.55, 3, 2 ];
+
+ t.plan(Object.keys(expected).reduce(function (sum, key) {
+ return sum + expected[key].length;
+ }, 0));
+
+ var a = split();
+ var b = through.obj(function (row, enc, next) {
+ this.push(JSON.parse(row));
+ next();
+ });
+ var c = through.obj(function (row, enc, next) { this.push(row.x); next() });
+ var d = through.obj(function (x, enc, next) { this.push(x * 111); next() });
+
+ var first = through.obj(function (row, enc, next) {
+ if (expected.first.length === 2) p.push(second);
+
+ var ex = expected.first.shift();
+ t.deepEqual(row, ex);
+
+ this.push(row / 100);
+ next();
+ });
+ var second = through.obj(function (row, enc, next) {
+ var ex = expected.second.shift();
+ t.deepEqual(row, ex);
+ this.push(Math.floor(10 - row));
+ next();
+ });
+
+ var p = pipeline.obj([ a, b, c, d, first ]);
+ p.pipe(through.obj(function (row, enc, next) {
+ var ex = expected.output.shift();
+ t.deepEqual(row, ex);
+ next();
+ }));
+
+ p.write('{"x":3}\n');
+ p.write('{"x":4}\n');
+ p.write('{"x":5}\n');
+ p.write('{"x":6}\n');
+ p.write('{"x":7}');
+ p.end();
+});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-stream-splicer.git
More information about the Pkg-javascript-commits
mailing list