|
|
@@ -136,7 +136,7 @@ describe('Source', function () {
|
|
|
.into(Sink.sum),
|
|
|
)
|
|
|
.run()
|
|
|
- assert.equal(result, 2 * arr.reduce((a, b) => a + b, 0))
|
|
|
+ assert.strictEqual(result, 2 * arr.reduce((a, b) => a + b, 0))
|
|
|
})
|
|
|
})
|
|
|
|
|
|
@@ -146,7 +146,33 @@ describe('Source', function () {
|
|
|
.via(Flow.of<number>().map(v => v * 2))
|
|
|
.into(Sink.sum)
|
|
|
.run()
|
|
|
- assert.equal(result, 2 * arr.reduce((a, b) => a + b, 0))
|
|
|
+ assert.strictEqual(result, 2 * arr.reduce((a, b) => a + b, 0))
|
|
|
})
|
|
|
})
|
|
|
+
|
|
|
+ it('should run with simple flatMap', async () => {
|
|
|
+ const result = await Source.fromArray<string[]>([
|
|
|
+ ['a', 'b', 'c'],
|
|
|
+ ['d', 'e', 'f'],
|
|
|
+ ])
|
|
|
+ .flatMap(arr => Source.fromArray(arr))
|
|
|
+ .into(Sink.reduce((a, b) => a + b, ''))
|
|
|
+ .run()
|
|
|
+ assert.strictEqual(result, 'abcdef')
|
|
|
+ })
|
|
|
+
|
|
|
+ it('should run with more complex flatMap', async () => {
|
|
|
+ const result = await Source.fromArray<string[]>([
|
|
|
+ ['a', 'b', 'c'],
|
|
|
+ ['d', 'e', 'f'],
|
|
|
+ ])
|
|
|
+ .flatMap(arr =>
|
|
|
+ Source.fromArray(arr)
|
|
|
+ .filter(v => v != 'c')
|
|
|
+ .map(v => v + v),
|
|
|
+ )
|
|
|
+ .into(Sink.reduce((a, b) => a + b, ''))
|
|
|
+ .run()
|
|
|
+ assert.strictEqual(result, 'aabbddeeff')
|
|
|
+ })
|
|
|
})
|