Skip to content

Commit

Permalink
Re-add async tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexagon committed Oct 13, 2024
1 parent 997c755 commit 8304e28
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions test/croner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -938,42 +938,47 @@ test(
}, 3500);
}),
);
*/
test(
"Job should be working after 1500 ms",
//@ts-ignore
timeout(4000, (resolve, reject) => {
(context, done) => {
let sleepPromise;
const job = new Cron("* * * * * *", async () => {
await sleep(2000);
job.stop();
sleepPromise = sleep(2000);
await sleepPromise;
});
setTimeout(() => {
setTimeout(async () => {
if (job.isBusy()) {
resolve();
await sleepPromise!;
done();
} else {
reject(new Error("Job should have been busy"));
/* Let it time out */
}
}, 1500);
}),
},
{ waitForCallback: true, timeout: 4000 },
);
test(
"Job should not be working after 3500 ms",
//@ts-ignore
timeout(4000, (resolve, reject) => {
"Job should not be working after 1500 ms",
(context, done) => {
let sleepPromise;
const job = new Cron("* * * * * *", async () => {
await sleep(2000);
job.stop();
sleepPromise = sleep(2000);
await sleepPromise;
});
setTimeout(() => {
if (!job.isBusy()) {
resolve();
setTimeout(async () => {
if (job.isBusy()) {
/* Let it time out */
} else {
reject(new Error("Job should not have been busy"));
await sleepPromise!;
done();
}
}, 3500);
}),
},
{ waitForCallback: true, timeout: 4000 },
);
*/
test("Fire-once should be supported by ISO 8601 string, past and .nextRun() should return null", function () {
let scheduler0 = new Cron("2020-01-01T00:00:00");
assertEquals(scheduler0.nextRun(), null);
Expand Down Expand Up @@ -1034,4 +1039,4 @@ test("Fire-once should be supported by date, future and .nextRun() should return
nextRun = scheduler0.nextRun();
assertEquals(nextRun && nextRun?.getTime() > refTime.getTime(), true);
assertEquals(nextRun && nextRun?.getTime() < refTime.getTime() + 4000, true);
});
});

0 comments on commit 8304e28

Please sign in to comment.