-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recover missing test case + remove unnecessary renaming and comments.
- Loading branch information
b0dea
committed
Nov 19, 2024
1 parent
8d66861
commit a1fb95b
Showing
1 changed file
with
11 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,15 +206,19 @@ describe('Test Pulse', () => { | |
}); | ||
|
||
describe('Test resumeOnRestart', () => { | ||
test('should enable resumeOnRestart by default', () => { | ||
test('sets the default resumeOnRestart', () => { | ||
expect(globalPulseInstance._resumeOnRestart).toBeTruthy(); | ||
}); | ||
|
||
test('should disable resumeOnRestart when set to false', () => { | ||
test('sets the custom resumeOnRestart', () => { | ||
globalPulseInstance.resumeOnRestart(false); | ||
expect(globalPulseInstance._resumeOnRestart).toBeFalsy(); | ||
}); | ||
|
||
test('returns itself', () => { | ||
expect(globalPulseInstance.resumeOnRestart(false)).toEqual(globalPulseInstance); | ||
}); | ||
|
||
test('should not reschedule successfully finished non-recurring jobs', async () => { | ||
const job = globalPulseInstance.create('sendEmail', { to: '[email protected]' }); | ||
job.attrs.lastFinishedAt = new Date(); | ||
|
@@ -305,14 +309,14 @@ describe('Test Pulse', () => { | |
const job = globalPulseInstance.create('processData', { data: 'sample' }); | ||
job.attrs.repeatInterval = '10 minutes'; | ||
job.attrs.lockedAt = new Date(); | ||
job.attrs.nextRunAt = new Date(Date.now() + 10000); // Next run in 10 seconds | ||
job.attrs.nextRunAt = new Date(Date.now() + 10000); | ||
await job.save(); | ||
|
||
await globalPulseInstance.resumeOnRestart(); | ||
|
||
const updatedJob = (await globalPulseInstance.jobs({ name: 'processData' }))[0]; | ||
expect(updatedJob.attrs.lockedAt).not.toBeNull(); // Job remains locked | ||
expect(updatedJob.attrs.nextRunAt).not.toBeNull(); // Scheduling intact | ||
expect(updatedJob.attrs.lockedAt).not.toBeNull(); | ||
expect(updatedJob.attrs.nextRunAt).not.toBeNull(); | ||
}); | ||
|
||
test('should handle interrupted recurring jobs after server recovery', async () => { | ||
|
@@ -331,14 +335,14 @@ describe('Test Pulse', () => { | |
|
||
test('should not modify non-recurring jobs with lastFinishedAt in the past', async () => { | ||
const job = globalPulseInstance.create('sendEmail', { to: '[email protected]' }); | ||
job.attrs.lastFinishedAt = new Date(Date.now() - 10000); // Finished 10 seconds ago | ||
job.attrs.lastFinishedAt = new Date(Date.now() - 10000); | ||
job.attrs.nextRunAt = null; | ||
await job.save(); | ||
|
||
await globalPulseInstance.resumeOnRestart(); | ||
|
||
const updatedJob = (await globalPulseInstance.jobs({ name: 'sendEmail' }))[0]; | ||
expect(updatedJob.attrs.nextRunAt).toBeNull(); // Job remains finished | ||
expect(updatedJob.attrs.nextRunAt).toBeNull(); | ||
}); | ||
}); | ||
}); | ||
|