[Pkg-javascript-commits] [node-stream-splicer] 08/71: failing pop test

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 816621f2c871c0ac1ade65b6ce62bada471bd478
Author: James Halliday <mail at substack.net>
Date:   Sun Jun 8 05:25:53 2014 -0700

    failing pop test
---
 test/pop.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/test/pop.js b/test/pop.js
new file mode 100644
index 0000000..63f9b59
--- /dev/null
+++ b/test/pop.js
@@ -0,0 +1,48 @@
+var pipeline = require('../');
+var through = require('through2');
+var split = require('split');
+var concat = require('concat-stream');
+var test = require('tape');
+
+test('pop', function (t) {
+    var expected = {};
+    expected.replacer = [ '333', '444' ];
+    
+    t.plan(Object.keys(expected).reduce(function (sum, key) {
+        return sum + expected[key].length;
+    }, 0) + 1);
+    
+    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(String(x * 111));
+        next();
+    });
+    var replacer = through(function (buf, enc, next) {
+        var ex = expected.replacer.shift();
+        t.equal(buf.toString(), ex);
+        this.push(buf.toString('hex') + '\n');
+        if (expected.replacer.length === 0) {
+            stream.pop();
+        }
+        next();
+    });
+    
+    var stream = pipeline([ a, b, c, d, replacer ]);
+    stream.pipe(concat(function (body) {
+        t.deepEqual(body.toString(), '333333\n343434555666');
+    }));
+    
+    stream.write('{"x":3}\n');
+    stream.write('{"x":4}\n');
+    stream.write('{"x":5}\n');
+    stream.write('{"x":6}');
+    stream.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