Skip to content

Commit

Permalink
Update tests to the new requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
justjanne committed Feb 7, 2023
1 parent 4210090 commit 4de8cf2
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions spec/unit/scheduler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe("MatrixScheduler", function () {
expect(procCount).toEqual(2);
});

it("should give up if the retryFn on failure returns -1 and try the next event", async function () {
it("should give up if the retryFn on failure returns -1", async function () {
// Queue A & B.
// Reject A and return -1 on retry.
// Expect B to be tried next and the promise for A to be rejected.
Expand All @@ -139,19 +139,15 @@ describe("MatrixScheduler", function () {
return new Promise<Record<string, boolean>>(() => {});
});

const globalA = scheduler.queueEvent(eventA);
scheduler.queueEvent(eventB);
const queuedA = scheduler.queueEvent(eventA);
const queuedB = scheduler.queueEvent(eventB);
await Promise.resolve();
deferA.reject(new Error("Testerror"));
// as queueing doesn't start processing synchronously anymore (see commit bbdb5ac)
// wait just long enough before it does
await Promise.resolve();
await expect(queuedA).rejects.toThrow("Testerror");
await expect(queuedB).rejects.toThrow("Testerror");
expect(procCount).toEqual(1);
deferA.reject({});
try {
await globalA;
} catch (err) {
await Promise.resolve();
expect(procCount).toEqual(2);
}
});

it("should treat each queue separately", function (done) {
Expand Down

0 comments on commit 4de8cf2

Please sign in to comment.