diff --git a/packages/rstream/test/pubsub.ts b/packages/rstream/test/pubsub.ts index dc540d98a3..e921f6c3a9 100644 --- a/packages/rstream/test/pubsub.ts +++ b/packages/rstream/test/pubsub.ts @@ -1,7 +1,6 @@ import { EquivMap } from "@thi.ng/associative"; import * as tx from "@thi.ng/transducers"; import * as assert from "assert"; - import * as rs from "../src/index"; describe("PubSub", () => { @@ -21,18 +20,32 @@ describe("PubSub", () => { }); it("complex keys", () => { - const acc = new EquivMap(); - const collect = { next: (x) => { let v = acc.get(x); v ? v.push(x) : acc.set(x, [x]) } }; + const acc = new EquivMap<[string, number], [string, number][]>(); + const collect = { + next: (x) => { + let v = acc.get(x); + v ? v.push(x) : acc.set(x, [x]); + } + }; pub = rs.pubsub({ topic: (x) => x }); pub.subscribeTopic(["a", 0], collect); pub.subscribeTopic(["a", 1], collect); pub.subscribeTopic(["b", 2], collect); - rs.fromIterableSync([["a", 0], ["a", 1], ["b", 2], ["a", 0], ["c", 3]]).subscribe(pub); - assert.deepEqual([...acc], [ - [["a", 0], [["a", 0], ["a", 0]]], - [["a", 1], [["a", 1]]], - [["b", 2], [["b", 2]]], - ]); + rs.fromIterableSync([ + ["a", 0], + ["a", 1], + ["b", 2], + ["a", 0], + ["c", 3] + ]).subscribe(pub); + assert.deepEqual( + [...acc], + [ + [["a", 0], [["a", 0], ["a", 0]]], + [["a", 1], [["a", 1]]], + [["b", 2], [["b", 2]]] + ] + ); assert.equal(pub.getState(), rs.State.DONE); }); @@ -46,7 +59,12 @@ describe("PubSub", () => { pub.subscribeTopic("a", collect); pub.subscribeTopic("b", collect); rs.fromIterableSync("abcbd").subscribe(pub); - assert.deepEqual(acc, { a: [["a", 0]], b: [["b", 1], ["b", 3]], c: [], d: [] }); + assert.deepEqual(acc, { + a: [["a", 0]], + b: [["b", 1], ["b", 3]], + c: [], + d: [] + }); assert.equal(pub.getState(), rs.State.DONE); }); @@ -64,5 +82,4 @@ describe("PubSub", () => { done(); }, 40); }); - -}); \ No newline at end of file +});