@@ -8,6 +8,7 @@ import DemoActorSayImpl from '../actor/DemoActorSayImpl';
8
8
import DemoActorTimerImpl from '../actor/DemoActorTimerImpl' ;
9
9
import ActorId from '../../src/actors/ActorId' ;
10
10
import ActorProxyBuilder from '../../src/actors/client/ActorProxyBuilder' ;
11
+ import * as NodeJSUtil from '../../src/utils/NodeJS.util' ;
11
12
12
13
const serverHost = "127.0.0.1" ;
13
14
const serverPort = "50001" ;
@@ -48,10 +49,26 @@ describe('http/actors', () => {
48
49
} , 30 * 1000 ) ;
49
50
50
51
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
52
53
// await client.stop();
53
54
} ) ;
54
55
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
+
55
72
describe ( 'actorProxy' , ( ) => {
56
73
it ( 'should be able to create an actor object through the proxy' , async ( ) => {
57
74
const builder = new ActorProxyBuilder < DemoActorCounterImpl > ( DemoActorCounterImpl , client ) ;
@@ -163,7 +180,7 @@ describe('http/actors', () => {
163
180
expect ( res0 ) . toEqual ( 0 ) ;
164
181
165
182
// Now we wait for dueTime (2s)
166
- await ( new Promise ( resolve => setTimeout ( resolve , 2000 ) ) ) ;
183
+ await NodeJSUtil . sleep ( 2000 ) ;
167
184
168
185
// After that the reminder callback will be called
169
186
// In our case, the callback increments the count attribute
0 commit comments