[Pkg-javascript-commits] [node-stream-splicer] 11/71: failing splice test

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 15 09:55:47 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 a81a597fd372d584545964dd494f0b508773dc4f
Author: James Halliday <mail at substack.net>
Date:   Sun Jun 8 05:37:02 2014 -0700

    failing splice test
---
 test/splice.js | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/test/splice.js b/test/splice.js
new file mode 100644
index 0000000..a4f3964
--- /dev/null
+++ b/test/splice.js
@@ -0,0 +1,57 @@
+var pipeline = require('../');
+var through = require('through2');
+var split = require('split');
+var concat = require('concat-stream');
+var test = require('tape');
+
+test('splice', function (t) {
+    var expected = {};
+    expected.replacer = [ '333', '444', '5000' ];
+    
+    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 thousander = through.obj(function (x, enc, next) {
+        this.push(String(x * 1000));
+        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 === 2) {
+            stream.splice(3, 1, thousander);
+        }
+        next();
+    });
+    
+    var stream = pipeline([ a, b, c, d, replacer ]);
+    stream.pipe(concat(function (body) {
+        t.deepEqual(
+            body.toString(),
+            '333333\n343434\n35303030\n36303030\n'
+        );
+    }));
+    
+    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