Skip to content

Commit

Permalink
(#556) Update testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
s1hofmann committed Feb 3, 2024
1 parent 6161475 commit 4be4423
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/util/timeout.function.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ describe("timeout", () => {
try {
await timeout(updateInterval, maxDuration, action);
} catch (e) {
expect(e).toBe(`Action timed out after ${maxDuration} ms`);
expect(e).toBe(
`Action timed out after ${maxDuration} ms. Last rejection reason was: false.`,
);
}
const end = Date.now();

Expand All @@ -37,7 +39,9 @@ describe("timeout", () => {
try {
await timeout(updateInterval, maxDuration, action);
} catch (e) {
expect(e).toEqual(`Action timed out after ${maxDuration} ms`);
expect(e).toEqual(
`Action timed out after ${maxDuration} ms. Didn't receive a result within timeout.`,
);
}
const end = Date.now();

Expand Down Expand Up @@ -90,7 +94,7 @@ describe("timeout", () => {
const action = jest.fn(() => {
const interval = Date.now() - start;
return new Promise<boolean>((resolve, reject) =>
interval > delay ? resolve(true) : reject()
interval > delay ? resolve(true) : reject(),
);
});

Expand All @@ -114,7 +118,9 @@ describe("timeout", () => {
try {
await timeout(updateInterval, maxDuration, action);
} catch (e) {
expect(e).toEqual(`Action timed out after ${maxDuration} ms`);
expect(e).toEqual(
`Action timed out after ${maxDuration} ms. Didn't receive a result within timeout.`,
);
}
const end = Date.now();

Expand All @@ -137,7 +143,9 @@ describe("timeout", () => {
const SUT = () => timeout(updateInterval, maxDuration, action);

// THEN
await expect(SUT).rejects.toBe(`Action timed out after ${maxDuration} ms`);
await expect(SUT).rejects.toBe(
`Action timed out after ${maxDuration} ms. Didn't receive a result within timeout.`,
);
expect(action).toBeCalledTimes(1);
});

Expand All @@ -157,7 +165,9 @@ describe("timeout", () => {
const SUT = () => timeout(updateInterval, maxDuration, action);

// THEN
await expect(SUT).rejects.toBe(`Action timed out after ${maxDuration} ms`);
await expect(SUT).rejects.toBe(
`Action timed out after ${maxDuration} ms. Didn't receive a result within timeout.`,
);
expect(action).toBeCalledTimes(1);
await sleep(500);
expect(action).toBeCalledTimes(1);
Expand Down

0 comments on commit 4be4423

Please sign in to comment.