@@ -7,7 +7,7 @@ describe('PromiseBuffer', () => {
7
7
const buffer = makePromiseBuffer ( ) ;
8
8
const p = jest . fn ( ( ) => new SyncPromise ( resolve => setTimeout ( resolve ) ) ) ;
9
9
void buffer . add ( p ) ;
10
- expect ( buffer . length ( ) ) . toEqual ( 1 ) ;
10
+ expect ( buffer . $ . length ) . toEqual ( 1 ) ;
11
11
} ) ;
12
12
13
13
test ( 'with limit' , ( ) => {
@@ -20,7 +20,7 @@ describe('PromiseBuffer', () => {
20
20
const producer2 = jest . fn ( ( ) => new SyncPromise ( resolve => setTimeout ( resolve ) ) ) ;
21
21
expect ( buffer . add ( producer1 ) ) . toEqual ( task1 ) ;
22
22
void expect ( buffer . add ( producer2 ) ) . rejects . toThrowError ( ) ;
23
- expect ( buffer . length ( ) ) . toEqual ( 1 ) ;
23
+ expect ( buffer . $ . length ) . toEqual ( 1 ) ;
24
24
expect ( producer1 ) . toHaveBeenCalled ( ) ;
25
25
expect ( producer2 ) . not . toHaveBeenCalled ( ) ;
26
26
} ) ;
@@ -32,51 +32,51 @@ describe('PromiseBuffer', () => {
32
32
for ( let i = 0 ; i < 5 ; i ++ ) {
33
33
void buffer . add ( ( ) => new SyncPromise ( resolve => setTimeout ( resolve ) ) ) ;
34
34
}
35
- expect ( buffer . length ( ) ) . toEqual ( 5 ) ;
35
+ expect ( buffer . $ . length ) . toEqual ( 5 ) ;
36
36
const result = await buffer . drain ( ) ;
37
37
expect ( result ) . toEqual ( true ) ;
38
- expect ( buffer . length ( ) ) . toEqual ( 0 ) ;
38
+ expect ( buffer . $ . length ) . toEqual ( 0 ) ;
39
39
} ) ;
40
40
41
41
test ( 'with timeout' , async ( ) => {
42
42
const buffer = makePromiseBuffer ( ) ;
43
43
for ( let i = 0 ; i < 5 ; i ++ ) {
44
44
void buffer . add ( ( ) => new SyncPromise ( resolve => setTimeout ( resolve , 100 ) ) ) ;
45
45
}
46
- expect ( buffer . length ( ) ) . toEqual ( 5 ) ;
46
+ expect ( buffer . $ . length ) . toEqual ( 5 ) ;
47
47
const result = await buffer . drain ( 50 ) ;
48
48
expect ( result ) . toEqual ( false ) ;
49
49
} ) ;
50
50
51
51
test ( 'on empty buffer' , async ( ) => {
52
52
const buffer = makePromiseBuffer ( ) ;
53
- expect ( buffer . length ( ) ) . toEqual ( 0 ) ;
53
+ expect ( buffer . $ . length ) . toEqual ( 0 ) ;
54
54
const result = await buffer . drain ( ) ;
55
55
expect ( result ) . toEqual ( true ) ;
56
- expect ( buffer . length ( ) ) . toEqual ( 0 ) ;
56
+ expect ( buffer . $ . length ) . toEqual ( 0 ) ;
57
57
} ) ;
58
58
} ) ;
59
59
60
60
test ( 'resolved promises should not show up in buffer length' , async ( ) => {
61
61
const buffer = makePromiseBuffer ( ) ;
62
62
const producer = ( ) => new SyncPromise ( resolve => setTimeout ( resolve ) ) ;
63
63
const task = buffer . add ( producer ) ;
64
- expect ( buffer . length ( ) ) . toEqual ( 1 ) ;
64
+ expect ( buffer . $ . length ) . toEqual ( 1 ) ;
65
65
await task ;
66
- expect ( buffer . length ( ) ) . toEqual ( 0 ) ;
66
+ expect ( buffer . $ . length ) . toEqual ( 0 ) ;
67
67
} ) ;
68
68
69
69
test ( 'rejected promises should not show up in buffer length' , async ( ) => {
70
70
const buffer = makePromiseBuffer ( ) ;
71
71
const producer = ( ) => new SyncPromise ( ( _ , reject ) => setTimeout ( reject ) ) ;
72
72
const task = buffer . add ( producer ) ;
73
- expect ( buffer . length ( ) ) . toEqual ( 1 ) ;
73
+ expect ( buffer . $ . length ) . toEqual ( 1 ) ;
74
74
try {
75
75
await task ;
76
76
} catch ( _ ) {
77
77
// no-empty
78
78
}
79
- expect ( buffer . length ( ) ) . toEqual ( 0 ) ;
79
+ expect ( buffer . $ . length ) . toEqual ( 0 ) ;
80
80
} ) ;
81
81
82
82
test ( 'resolved task should give an access to the return value' , async ( ) => {
0 commit comments