Add chunk to constructor (#5)

* Add chunk to constructor

* Add test

* Bump version
This commit is contained in:
Jerry Kurian
2020-04-27 12:25:36 -04:00
committed by GitHub
parent f661f9be6b
commit 71b03678ba
3 changed files with 33 additions and 13 deletions

View File

@@ -44,6 +44,34 @@ test.cb("demux() constructor should be called once per key", t => {
fromArray(input).pipe(demuxed);
});
test.cb("demux() item written passed in constructor", t => {
t.plan(4);
const input = [
{ key: "a", visited: [] },
{ key: "b", visited: [] },
{ key: "c", visited: [] },
];
const construct = sinon.spy((destKey: string, item: any) => {
expect(item).to.deep.equal({ key: destKey, visited: [] });
t.pass();
const dest = map((chunk: Test) => {
chunk.visited.push(1);
return chunk;
});
return dest;
});
const demuxed = demux(construct, "key", {});
demuxed.on("finish", () => {
t.pass();
t.end();
});
fromArray(input).pipe(demuxed);
});
test.cb("demux() should send input through correct pipeline", t => {
t.plan(6);
const input = [