@@ -32,32 +32,31 @@ describe('listen', () => {
3232 const result = createController ( ) . listen ( commands ) . finally ( finallyCallback ) ;
3333
3434 // Emitting multiple close events to mimic calling command `kill/start` APIs.
35- commands [ 0 ] . close . next ( createFakeCloseEvent ( { exitCode : 0 } ) ) ;
36- commands [ 0 ] . close . next ( createFakeCloseEvent ( { exitCode : 0 } ) ) ;
37- commands [ 0 ] . close . next ( createFakeCloseEvent ( { exitCode : 0 } ) ) ;
35+ emitFakeCloseEvent ( commands [ 0 ] ) ;
36+ emitFakeCloseEvent ( commands [ 0 ] ) ;
37+ emitFakeCloseEvent ( commands [ 0 ] ) ;
3838
3939 scheduler . flush ( ) ;
4040 // A broken implementantion will have called finallyCallback only after flushing promises
4141 await flushPromises ( ) ;
4242 expect ( finallyCallback ) . not . toHaveBeenCalled ( ) ;
4343
44- commands [ 1 ] . close . next ( createFakeCloseEvent ( { exitCode : 0 } ) ) ;
45- commands [ 2 ] . close . next ( createFakeCloseEvent ( { exitCode : 0 } ) ) ;
44+ emitFakeCloseEvent ( commands [ 1 ] ) ;
45+ emitFakeCloseEvent ( commands [ 2 ] ) ;
4646
4747 scheduler . flush ( ) ;
4848
4949 await expect ( result ) . resolves . toEqual ( expect . anything ( ) ) ;
50-
5150 expect ( finallyCallback ) . toHaveBeenCalled ( ) ;
5251 } ) ;
5352
5453 it ( 'takes last event emitted from each command' , async ( ) => {
5554 const result = createController ( ) . listen ( commands ) ;
5655
57- commands [ 0 ] . close . next ( createFakeCloseEvent ( { exitCode : 0 } ) ) ;
58- commands [ 0 ] . close . next ( createFakeCloseEvent ( { exitCode : 1 } ) ) ;
59- commands [ 1 ] . close . next ( createFakeCloseEvent ( { exitCode : 0 } ) ) ;
60- commands [ 2 ] . close . next ( createFakeCloseEvent ( { exitCode : 0 } ) ) ;
56+ emitFakeCloseEvent ( commands [ 0 ] , { exitCode : 0 } ) ;
57+ emitFakeCloseEvent ( commands [ 0 ] , { exitCode : 1 } ) ;
58+ emitFakeCloseEvent ( commands [ 1 ] , { exitCode : 0 } ) ;
59+ emitFakeCloseEvent ( commands [ 2 ] , { exitCode : 0 } ) ;
6160
6261 scheduler . flush ( ) ;
6362
@@ -68,18 +67,18 @@ describe('listen', () => {
6867 const finallyCallback = jest . fn ( ) ;
6968 const result = createController ( ) . listen ( commands ) . finally ( finallyCallback ) ;
7069
71- commands [ 0 ] . close . next ( createFakeCloseEvent ( ) ) ;
70+ emitFakeCloseEvent ( commands [ 0 ] ) ;
7271 commands [ 0 ] . state = 'started' ;
73- commands [ 1 ] . close . next ( createFakeCloseEvent ( ) ) ;
74- commands [ 2 ] . close . next ( createFakeCloseEvent ( ) ) ;
72+ emitFakeCloseEvent ( commands [ 1 ] ) ;
73+ emitFakeCloseEvent ( commands [ 2 ] ) ;
7574
7675 scheduler . flush ( ) ;
7776 // A broken implementantion will have called finallyCallback only after flushing promises
7877 await flushPromises ( ) ;
7978 expect ( finallyCallback ) . not . toHaveBeenCalled ( ) ;
8079
8180 commands [ 0 ] . state = 'exited' ;
82- commands [ 0 ] . close . next ( createFakeCloseEvent ( ) ) ;
81+ emitFakeCloseEvent ( commands [ 0 ] ) ;
8382 scheduler . flush ( ) ;
8483
8584 await expect ( result ) . resolves . toEqual ( expect . anything ( ) ) ;
0 commit comments