@@ -3,8 +3,8 @@ import { Hub } from '@sentry/hub';
33
44import {
55 DEFAULT_FINAL_TIMEOUT ,
6+ DEFAULT_HEARTBEAT_INTERVAL ,
67 DEFAULT_IDLE_TIMEOUT ,
7- HEARTBEAT_INTERVAL ,
88 IdleTransaction ,
99 IdleTransactionSpanRecorder ,
1010} from '../src/idletransaction' ;
@@ -21,7 +21,14 @@ beforeEach(() => {
2121describe ( 'IdleTransaction' , ( ) => {
2222 describe ( 'onScope' , ( ) => {
2323 it ( 'sets the transaction on the scope on creation if onScope is true' , ( ) => {
24- const transaction = new IdleTransaction ( { name : 'foo' } , hub , DEFAULT_IDLE_TIMEOUT , DEFAULT_FINAL_TIMEOUT , true ) ;
24+ const transaction = new IdleTransaction (
25+ { name : 'foo' } ,
26+ hub ,
27+ DEFAULT_IDLE_TIMEOUT ,
28+ DEFAULT_FINAL_TIMEOUT ,
29+ DEFAULT_HEARTBEAT_INTERVAL ,
30+ true ,
31+ ) ;
2532 transaction . initSpanRecorder ( 10 ) ;
2633
2734 hub . configureScope ( s => {
@@ -39,7 +46,14 @@ describe('IdleTransaction', () => {
3946 } ) ;
4047
4148 it ( 'removes sampled transaction from scope on finish if onScope is true' , ( ) => {
42- const transaction = new IdleTransaction ( { name : 'foo' } , hub , DEFAULT_IDLE_TIMEOUT , DEFAULT_FINAL_TIMEOUT , true ) ;
49+ const transaction = new IdleTransaction (
50+ { name : 'foo' } ,
51+ hub ,
52+ DEFAULT_IDLE_TIMEOUT ,
53+ DEFAULT_FINAL_TIMEOUT ,
54+ DEFAULT_HEARTBEAT_INTERVAL ,
55+ true ,
56+ ) ;
4357 transaction . initSpanRecorder ( 10 ) ;
4458
4559 transaction . finish ( ) ;
@@ -56,6 +70,7 @@ describe('IdleTransaction', () => {
5670 hub ,
5771 DEFAULT_IDLE_TIMEOUT ,
5872 DEFAULT_FINAL_TIMEOUT ,
73+ DEFAULT_HEARTBEAT_INTERVAL ,
5974 true ,
6075 ) ;
6176
@@ -248,17 +263,17 @@ describe('IdleTransaction', () => {
248263 expect ( mockFinish ) . toHaveBeenCalledTimes ( 0 ) ;
249264
250265 // Beat 1
251- jest . advanceTimersByTime ( HEARTBEAT_INTERVAL ) ;
266+ jest . advanceTimersByTime ( DEFAULT_HEARTBEAT_INTERVAL ) ;
252267 expect ( transaction . status ) . not . toEqual ( 'deadline_exceeded' ) ;
253268 expect ( mockFinish ) . toHaveBeenCalledTimes ( 0 ) ;
254269
255270 // Beat 2
256- jest . advanceTimersByTime ( HEARTBEAT_INTERVAL ) ;
271+ jest . advanceTimersByTime ( DEFAULT_HEARTBEAT_INTERVAL ) ;
257272 expect ( transaction . status ) . not . toEqual ( 'deadline_exceeded' ) ;
258273 expect ( mockFinish ) . toHaveBeenCalledTimes ( 0 ) ;
259274
260275 // Beat 3
261- jest . advanceTimersByTime ( HEARTBEAT_INTERVAL ) ;
276+ jest . advanceTimersByTime ( DEFAULT_HEARTBEAT_INTERVAL ) ;
262277 expect ( transaction . status ) . not . toEqual ( 'deadline_exceeded' ) ;
263278 expect ( mockFinish ) . toHaveBeenCalledTimes ( 0 ) ;
264279 } ) ;
@@ -272,15 +287,15 @@ describe('IdleTransaction', () => {
272287 transaction . startChild ( { } ) ;
273288
274289 // Beat 1
275- jest . advanceTimersByTime ( HEARTBEAT_INTERVAL ) ;
290+ jest . advanceTimersByTime ( DEFAULT_HEARTBEAT_INTERVAL ) ;
276291 expect ( mockFinish ) . toHaveBeenCalledTimes ( 0 ) ;
277292
278293 // Beat 2
279- jest . advanceTimersByTime ( HEARTBEAT_INTERVAL ) ;
294+ jest . advanceTimersByTime ( DEFAULT_HEARTBEAT_INTERVAL ) ;
280295 expect ( mockFinish ) . toHaveBeenCalledTimes ( 0 ) ;
281296
282297 // Beat 3
283- jest . advanceTimersByTime ( HEARTBEAT_INTERVAL ) ;
298+ jest . advanceTimersByTime ( DEFAULT_HEARTBEAT_INTERVAL ) ;
284299 expect ( mockFinish ) . toHaveBeenCalledTimes ( 1 ) ;
285300 } ) ;
286301
@@ -293,42 +308,42 @@ describe('IdleTransaction', () => {
293308 transaction . startChild ( { } ) ;
294309
295310 // Beat 1
296- jest . advanceTimersByTime ( HEARTBEAT_INTERVAL ) ;
311+ jest . advanceTimersByTime ( DEFAULT_HEARTBEAT_INTERVAL ) ;
297312 expect ( mockFinish ) . toHaveBeenCalledTimes ( 0 ) ;
298313
299314 const span = transaction . startChild ( ) ; // push activity
300315
301316 // Beat 1
302- jest . advanceTimersByTime ( HEARTBEAT_INTERVAL ) ;
317+ jest . advanceTimersByTime ( DEFAULT_HEARTBEAT_INTERVAL ) ;
303318 expect ( mockFinish ) . toHaveBeenCalledTimes ( 0 ) ;
304319
305320 // Beat 2
306- jest . advanceTimersByTime ( HEARTBEAT_INTERVAL ) ;
321+ jest . advanceTimersByTime ( DEFAULT_HEARTBEAT_INTERVAL ) ;
307322 expect ( mockFinish ) . toHaveBeenCalledTimes ( 0 ) ;
308323
309324 transaction . startChild ( ) ; // push activity
310325 transaction . startChild ( ) ; // push activity
311326
312327 // Beat 1
313- jest . advanceTimersByTime ( HEARTBEAT_INTERVAL ) ;
328+ jest . advanceTimersByTime ( DEFAULT_HEARTBEAT_INTERVAL ) ;
314329 expect ( mockFinish ) . toHaveBeenCalledTimes ( 0 ) ;
315330
316331 // Beat 2
317- jest . advanceTimersByTime ( HEARTBEAT_INTERVAL ) ;
332+ jest . advanceTimersByTime ( DEFAULT_HEARTBEAT_INTERVAL ) ;
318333 expect ( mockFinish ) . toHaveBeenCalledTimes ( 0 ) ;
319334
320335 span . finish ( ) ; // pop activity
321336
322337 // Beat 1
323- jest . advanceTimersByTime ( HEARTBEAT_INTERVAL ) ;
338+ jest . advanceTimersByTime ( DEFAULT_HEARTBEAT_INTERVAL ) ;
324339 expect ( mockFinish ) . toHaveBeenCalledTimes ( 0 ) ;
325340
326341 // Beat 2
327- jest . advanceTimersByTime ( HEARTBEAT_INTERVAL ) ;
342+ jest . advanceTimersByTime ( DEFAULT_HEARTBEAT_INTERVAL ) ;
328343 expect ( mockFinish ) . toHaveBeenCalledTimes ( 0 ) ;
329344
330345 // Beat 3
331- jest . advanceTimersByTime ( HEARTBEAT_INTERVAL ) ;
346+ jest . advanceTimersByTime ( DEFAULT_HEARTBEAT_INTERVAL ) ;
332347 expect ( mockFinish ) . toHaveBeenCalledTimes ( 1 ) ;
333348
334349 // Heartbeat does not keep going after finish has been called
0 commit comments