File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
packages/core/test/lib/utils Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,27 @@ describe('PromiseBuffer', () => {
3434 expect ( producer1 ) . toHaveBeenCalled ( ) ;
3535 expect ( producer2 ) . not . toHaveBeenCalled ( ) ;
3636 } ) ;
37+
38+ test ( 'handles multiple equivalent promises' , async ( ) => {
39+ const buffer = makePromiseBuffer ( 10 ) ;
40+
41+ const promise = new Promise ( resolve => setTimeout ( resolve , 1 ) ) ;
42+
43+ const producer = vi . fn ( ( ) => promise ) ;
44+ const producer2 = vi . fn ( ( ) => promise ) ;
45+
46+ expect ( buffer . add ( producer ) ) . toEqual ( promise ) ;
47+ expect ( buffer . add ( producer2 ) ) . toEqual ( promise ) ;
48+
49+ expect ( buffer . $ . length ) . toEqual ( 1 ) ;
50+
51+ expect ( producer ) . toHaveBeenCalled ( ) ;
52+ expect ( producer2 ) . toHaveBeenCalled ( ) ;
53+
54+ await buffer . drain ( ) ;
55+
56+ expect ( buffer . $ . length ) . toEqual ( 0 ) ;
57+ } ) ;
3758 } ) ;
3859
3960 describe ( 'drain()' , ( ) => {
You can’t perform that action at this time.
0 commit comments