@@ -206,15 +206,19 @@ describe('Test Pulse', () => {
206206 } ) ;
207207
208208 describe ( 'Test resumeOnRestart' , ( ) => {
209- test ( 'should enable resumeOnRestart by default' , ( ) => {
209+ test ( 'sets the default resumeOnRestart ' , ( ) => {
210210 expect ( globalPulseInstance . _resumeOnRestart ) . toBeTruthy ( ) ;
211211 } ) ;
212212
213- test ( 'should disable resumeOnRestart when set to false ' , ( ) => {
213+ test ( 'sets the custom resumeOnRestart ' , ( ) => {
214214 globalPulseInstance . resumeOnRestart ( false ) ;
215215 expect ( globalPulseInstance . _resumeOnRestart ) . toBeFalsy ( ) ;
216216 } ) ;
217217
218+ test ( 'returns itself' , ( ) => {
219+ expect ( globalPulseInstance . resumeOnRestart ( false ) ) . toEqual ( globalPulseInstance ) ;
220+ } ) ;
221+
218222 test ( 'should not reschedule successfully finished non-recurring jobs' , async ( ) => {
219223 const job = globalPulseInstance . create ( 'sendEmail' , { to : 'user@example.com' } ) ;
220224 job . attrs . lastFinishedAt = new Date ( ) ;
@@ -305,14 +309,14 @@ describe('Test Pulse', () => {
305309 const job = globalPulseInstance . create ( 'processData' , { data : 'sample' } ) ;
306310 job . attrs . repeatInterval = '10 minutes' ;
307311 job . attrs . lockedAt = new Date ( ) ;
308- job . attrs . nextRunAt = new Date ( Date . now ( ) + 10000 ) ; // Next run in 10 seconds
312+ job . attrs . nextRunAt = new Date ( Date . now ( ) + 10000 ) ;
309313 await job . save ( ) ;
310314
311315 await globalPulseInstance . resumeOnRestart ( ) ;
312316
313317 const updatedJob = ( await globalPulseInstance . jobs ( { name : 'processData' } ) ) [ 0 ] ;
314- expect ( updatedJob . attrs . lockedAt ) . not . toBeNull ( ) ; // Job remains locked
315- expect ( updatedJob . attrs . nextRunAt ) . not . toBeNull ( ) ; // Scheduling intact
318+ expect ( updatedJob . attrs . lockedAt ) . not . toBeNull ( ) ;
319+ expect ( updatedJob . attrs . nextRunAt ) . not . toBeNull ( ) ;
316320 } ) ;
317321
318322 test ( 'should handle interrupted recurring jobs after server recovery' , async ( ) => {
@@ -331,14 +335,14 @@ describe('Test Pulse', () => {
331335
332336 test ( 'should not modify non-recurring jobs with lastFinishedAt in the past' , async ( ) => {
333337 const job = globalPulseInstance . create ( 'sendEmail' , { to : 'user@example.com' } ) ;
334- job . attrs . lastFinishedAt = new Date ( Date . now ( ) - 10000 ) ; // Finished 10 seconds ago
338+ job . attrs . lastFinishedAt = new Date ( Date . now ( ) - 10000 ) ;
335339 job . attrs . nextRunAt = null ;
336340 await job . save ( ) ;
337341
338342 await globalPulseInstance . resumeOnRestart ( ) ;
339343
340344 const updatedJob = ( await globalPulseInstance . jobs ( { name : 'sendEmail' } ) ) [ 0 ] ;
341- expect ( updatedJob . attrs . nextRunAt ) . toBeNull ( ) ; // Job remains finished
345+ expect ( updatedJob . attrs . nextRunAt ) . toBeNull ( ) ;
342346 } ) ;
343347 } ) ;
344348 } ) ;
0 commit comments