Parcourir la source

remove duplicate test

Aurélien Richez il y a 5 ans
Parent
commit
b7f510498f
1 fichiers modifiés avec 6 ajouts et 18 suppressions
  1. 6 18
      src/streams.test.ts

+ 6 - 18
src/streams.test.ts

@@ -47,14 +47,15 @@ describe('Source', function () {
     )
   })
 
-  it('should run async computations', async () => {
+  it('should run ordered async', async () => {
     await fc.assert(
-      fc.asyncProperty(fc.array(fc.integer()), async (arr) => {
+      fc.asyncProperty(fc.array(fc.integer()), fc.integer(1, 50), async (arr, concurrencyLevel) => {
+        const timeout = () => (1 + (0 | (Math.random() * 4)))
         const result = await Source.fromArray(arr)
-          .mapAsync(50, v => { return new Promise(resolve => setTimeout(() => resolve(v * 2), 2)) })
-          .into(Sink.sum)
+          .mapAsync(concurrencyLevel, v => { return new Promise(resolve => setTimeout(() => resolve(v), timeout())) })
+          .into(Sink.reduce<number, number[]>((acc, b) => ([...acc, b]), []))
           .run()
-        assert.equal(result, 2 * arr.reduce((a, b) => a + b, 0))
+        assert.deepEqual(result, arr)
       })
     )
   })
@@ -71,19 +72,6 @@ describe('Source', function () {
     )
   })
 
-  it('should run async computations while keeping order', async () => {
-    await fc.assert(
-      fc.asyncProperty(fc.array(fc.integer()), fc.integer(1, 50), async (arr, concurrencyLevel) => {
-        const timeout = () => (1 + (0 | (Math.random() * 4)))
-        const result = await Source.fromArray(arr)
-          .mapAsync(concurrencyLevel, v => { return new Promise(resolve => setTimeout(() => resolve(v), timeout())) })
-          .into(Sink.reduce<number, number[]>((acc, b) => ([...acc, b]), []))
-          .run()
-        assert.deepEqual(result, arr)
-      })
-    )
-  })
-
   it('should filter elements', async () => {
     await fc.assert(
       fc.asyncProperty(fc.array(fc.integer()), async (arr) => {