@@ -8,6 +8,7 @@ import DemoActorSayImpl from '../actor/DemoActorSayImpl';
88import DemoActorTimerImpl from '../actor/DemoActorTimerImpl' ;
99import ActorId from '../../src/actors/ActorId' ;
1010import ActorProxyBuilder from '../../src/actors/client/ActorProxyBuilder' ;
11+ import * as NodeJSUtil from '../../src/utils/NodeJS.util' ;
1112
1213const serverHost = "127.0.0.1" ;
1314const serverPort = "50001" ;
@@ -48,10 +49,26 @@ describe('http/actors', () => {
4849 } , 30 * 1000 ) ;
4950
5051 afterAll ( async ( ) => {
51- // await server.stop();
52+ await server . stop ( ) ; // if we hang here, it means connections are open that were not closed. Debug why
5253 // await client.stop();
5354 } ) ;
5455
56+ describe ( 'general' , ( ) => {
57+ it ( 'should allow us to use promises as some testing libraries have issues within the Node Ecosystem' , async ( ) => {
58+ const mock = jest . fn ( ( ) => {
59+ return new Promise ( ( resolve ) => setTimeout ( resolve , 500 ) ) ;
60+ } ) ;
61+
62+ const handler = jest . fn ( ) ;
63+
64+ await mock ( ) . then ( handler ) ;
65+
66+ await ( new Promise ( resolve => setTimeout ( resolve , 2000 ) ) ) ;
67+
68+ expect ( handler ) . toHaveBeenCalled ( ) ;
69+ } ) ;
70+ } ) ;
71+
5572 describe ( 'actorProxy' , ( ) => {
5673 it ( 'should be able to create an actor object through the proxy' , async ( ) => {
5774 const builder = new ActorProxyBuilder < DemoActorCounterImpl > ( DemoActorCounterImpl , client ) ;
@@ -163,7 +180,7 @@ describe('http/actors', () => {
163180 expect ( res0 ) . toEqual ( 0 ) ;
164181
165182 // Now we wait for dueTime (2s)
166- await ( new Promise ( resolve => setTimeout ( resolve , 2000 ) ) ) ;
183+ await NodeJSUtil . sleep ( 2000 ) ;
167184
168185 // After that the reminder callback will be called
169186 // In our case, the callback increments the count attribute
0 commit comments