@@ -20,50 +20,3 @@ describe('forget', () => {
20
20
} ) ;
21
21
} ) ;
22
22
} ) ;
23
-
24
- describe ( 'filterAsync' , ( ) => {
25
- test ( 'filters with sync predicate' , async ( ) => {
26
- expect . assertions ( 1 ) ;
27
- const filtered = await filterAsync ( [ 1 , 2 , 3 , 4 ] , i => i > 2 ) ;
28
- expect ( filtered ) . toEqual ( [ 3 , 4 ] ) ;
29
- } ) ;
30
-
31
- test ( 'filters with async predicate' , async ( ) => {
32
- expect . assertions ( 1 ) ;
33
-
34
- const predicate = async ( i : number ) =>
35
- new Promise < boolean > ( resolve =>
36
- setTimeout ( ( ) => {
37
- resolve ( i > 2 ) ;
38
- } , i * 100 ) ,
39
- ) ;
40
-
41
- const filtered = await filterAsync ( [ 1 , 2 , 3 , 4 ] , predicate ) ;
42
- expect ( filtered ) . toEqual ( [ 3 , 4 ] ) ;
43
- } ) ;
44
-
45
- test ( 'passes filter arguments to the predicate' , async ( ) => {
46
- expect . assertions ( 1 ) ;
47
-
48
- const arr = [ 1 ] ;
49
- const predicate = jest . fn ( ) ;
50
-
51
- await filterAsync ( arr , predicate ) ;
52
- expect ( predicate ) . toHaveBeenCalledWith ( 1 , 0 , arr ) ;
53
- } ) ;
54
-
55
- test ( 'passes this to the predicate' , async ( ) => {
56
- expect . assertions ( 1 ) ;
57
-
58
- const that = { } ;
59
- await filterAsync (
60
- [ 1 ] ,
61
- function predicate ( this : { } ) : boolean {
62
- // tslint:disable-next-line:no-inferred-empty-object-type
63
- expect ( this ) . toBe ( that ) ;
64
- return false ;
65
- } ,
66
- that ,
67
- ) ;
68
- } ) ;
69
- } ) ;
0 commit comments