@@ -63,6 +63,8 @@ describe('http/actors', () => {
63
63
await server . actor . registerActor ( DemoActorReminder2Impl ) ;
64
64
await server . actor . registerActor ( DemoActorTimerImpl ) ;
65
65
await server . actor . registerActor ( DemoActorActivateImpl ) ;
66
+ await server . actor . registerActor ( DemoActorTimerTtlImpl ) ;
67
+ await server . actor . registerActor ( DemoActorReminderTtlImpl ) ;
66
68
67
69
// Start server
68
70
await server . start ( ) ; // Start the general server, this can take a while
@@ -99,13 +101,15 @@ describe('http/actors', () => {
99
101
it ( 'should register actors correctly' , async ( ) => {
100
102
const actors = await server . actor . getRegisteredActors ( ) ;
101
103
102
- expect ( actors . length ) . toEqual ( 6 ) ;
104
+ expect ( actors . length ) . toEqual ( 8 ) ;
103
105
104
106
expect ( actors ) . toContain ( DemoActorCounterImpl . name ) ;
105
107
expect ( actors ) . toContain ( DemoActorSayImpl . name ) ;
106
108
expect ( actors ) . toContain ( DemoActorReminderImpl . name ) ;
107
109
expect ( actors ) . toContain ( DemoActorTimerImpl . name ) ;
108
110
expect ( actors ) . toContain ( DemoActorActivateImpl . name ) ;
111
+ expect ( actors ) . toContain ( DemoActorTimerTtlImpl . name ) ;
112
+ expect ( actors ) . toContain ( DemoActorReminderTtlImpl . name ) ;
109
113
} ) ;
110
114
111
115
it ( 'should be able to invoke an actor through a text message' , async ( ) => {
@@ -186,7 +190,7 @@ describe('http/actors', () => {
186
190
expect ( res0 ) . toEqual ( 0 ) ;
187
191
188
192
// Now we wait for dueTime (2s)
189
- await ( new Promise ( resolve => setTimeout ( resolve , 500 ) ) ) ;
193
+ await ( new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ) ;
190
194
191
195
// After that the timer callback will be called
192
196
// In our case, the callback increments the count attribute
@@ -196,18 +200,10 @@ describe('http/actors', () => {
196
200
197
201
// Every 1 second the timer gets called again, so the count attribute should change
198
202
// we check this twice to ensure correct calling
199
- await ( new Promise ( resolve => setTimeout ( resolve , 500 ) ) ) ;
203
+ await ( new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ) ;
200
204
const res2 = await actor . getCounter ( ) ;
201
205
expect ( res2 ) . toEqual ( 200 ) ;
202
206
203
- await ( new Promise ( resolve => setTimeout ( resolve , 500 ) ) ) ;
204
- try {
205
- const res3 = await actor . getCounter ( ) ;
206
- } catch ( e ) {
207
- //@ts -ignore
208
- console . log ( e . message )
209
- }
210
- // expect(res3).toEqual(300);
211
207
} , 10000 ) ;
212
208
} ) ;
213
209
@@ -288,14 +284,11 @@ describe('http/actors', () => {
288
284
289
285
await actor . removeReminder ( ) ;
290
286
291
- await ( new Promise ( resolve => setTimeout ( resolve , 500 ) ) ) ;
292
- try {
293
- const res2 = await actor . getCounter ( ) ;
294
- } catch ( e ) {
295
- //@ts -ignore
296
- console . log ( e . message )
297
- }
298
- // expect(res2).toEqual(123);
287
+ await ( new Promise ( resolve => setTimeout ( resolve , 2000 ) ) ) ;
288
+
289
+ // Make sure the counter didn't change
290
+ const res2 = await actor . getCounter ( ) ;
291
+ expect ( res2 ) . toEqual ( 123 ) ;
299
292
} ) ;
300
293
} ) ;
301
294
} ) ;
0 commit comments