@@ -8,12 +8,9 @@ import {
8
8
range ,
9
9
toAsync ,
10
10
} from "../../src/index" ;
11
- import { callFuncAfterTime } from "../utils" ;
12
11
13
12
describe ( "concurrent" , function ( ) {
14
13
it ( "should be consumed 'AsyncIterable' concurrently" , async function ( ) {
15
- const fn = jest . fn ( ) ;
16
- callFuncAfterTime ( fn , 2000 ) ;
17
14
const res = concurrent (
18
15
2 ,
19
16
toAsync (
@@ -29,14 +26,10 @@ describe("concurrent", function () {
29
26
for await ( const item of res ) {
30
27
acc . push ( item ) ;
31
28
}
32
- expect ( fn ) . toBeCalled ( ) ;
33
29
expect ( acc ) . toEqual ( [ 1 , 2 , 3 , 4 ] ) ;
34
30
} , 2050 ) ;
35
31
36
32
it ( "should be able to be used as a curried function in the pipeline" , async function ( ) {
37
- const fn = jest . fn ( ) ;
38
- callFuncAfterTime ( fn , 500 ) ;
39
-
40
33
const iter = pipe (
41
34
toAsync ( range ( 1 , 101 ) ) ,
42
35
map ( ( a ) => delay ( 100 , a ) ) ,
@@ -56,13 +49,10 @@ describe("concurrent", function () {
56
49
iter . next ( ) ,
57
50
] ) . then ( ( arr ) => arr . map ( ( a ) => a . value ) ) ;
58
51
59
- expect ( fn ) . toBeCalled ( ) ;
60
52
expect ( arr ) . toEqual ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ) ;
61
53
} , 550 ) ;
62
54
63
55
it ( "should be affected only one concurrent below it, when nested concurrent" , async function ( ) {
64
- let fn : jest . Mock < any , any > ;
65
- fn = jest . fn ( ) ;
66
56
let concurrent10Count = 0 ;
67
57
let concurrent2Count = 0 ;
68
58
@@ -77,33 +67,23 @@ describe("concurrent", function () {
77
67
concurrent ( 2 ) ,
78
68
) ;
79
69
80
- callFuncAfterTime ( fn , 300 ) ;
81
70
await iter . next ( ) ;
82
71
await iter . next ( ) ;
83
- expect ( fn ) . toBeCalled ( ) ;
84
72
expect ( concurrent2Count ) . toEqual ( 4 ) ;
85
73
expect ( concurrent10Count ) . toEqual ( 10 ) ;
86
74
87
- fn = jest . fn ( ) ;
88
- callFuncAfterTime ( fn , 200 ) ;
89
75
await iter . next ( ) ;
90
76
await iter . next ( ) ;
91
- expect ( fn ) . toBeCalled ( ) ;
92
77
expect ( concurrent2Count ) . toEqual ( 8 ) ;
93
78
expect ( concurrent10Count ) . toEqual ( 10 ) ;
94
79
95
- fn = jest . fn ( ) ;
96
- callFuncAfterTime ( fn , 300 ) ;
97
80
await iter . next ( ) ;
98
81
await iter . next ( ) ;
99
- expect ( fn ) . toBeCalled ( ) ;
100
82
expect ( concurrent2Count ) . toEqual ( 12 ) ;
101
83
expect ( concurrent10Count ) . toEqual ( 20 ) ;
102
84
} , 850 ) ;
103
85
104
86
it ( "should return IteratorReturnResult after all consuming 'AsyncIterable'" , async function ( ) {
105
- const fn = jest . fn ( ) ;
106
- callFuncAfterTime ( fn , 1000 ) ;
107
87
const iter = concurrent (
108
88
2 ,
109
89
toAsync (
@@ -121,7 +101,6 @@ describe("concurrent", function () {
121
101
{ value : v4 , done : d4 } ,
122
102
] = await Promise . all ( [ iter . next ( ) , iter . next ( ) , iter . next ( ) , iter . next ( ) ] ) ;
123
103
124
- expect ( fn ) . toBeCalled ( ) ;
125
104
expect ( v1 ) . toEqual ( 1 ) ;
126
105
expect ( d1 ) . toEqual ( false ) ;
127
106
expect ( v2 ) . toEqual ( 2 ) ;
@@ -133,8 +112,6 @@ describe("concurrent", function () {
133
112
} , 1050 ) ;
134
113
135
114
it ( "should be able to handle an error when working concurrent" , async function ( ) {
136
- const fn = jest . fn ( ) ;
137
- callFuncAfterTime ( fn , 2000 ) ;
138
115
const res = concurrent (
139
116
2 ,
140
117
toAsync (
@@ -158,7 +135,6 @@ describe("concurrent", function () {
158
135
} catch ( err ) {
159
136
expect ( err ) . toEqual ( "err" ) ;
160
137
}
161
- expect ( fn ) . toBeCalled ( ) ;
162
138
expect ( acc ) . toEqual ( [ 1 , 2 , 3 ] ) ;
163
139
} , 2050 ) ;
164
140
} ) ;
0 commit comments