Skip to content
This repository was archived by the owner on Oct 27, 2025. It is now read-only.

Commit a1fb95b

Browse files
author
b0dea
committed
Recover missing test case + remove unnecessary renaming and comments.
1 parent 8d66861 commit a1fb95b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

test/unit/pulse.spec.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)