Skip to content

Commit 4be4423

Browse files
committed
(#556) Update testcases
1 parent 6161475 commit 4be4423

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

lib/util/timeout.function.spec.ts

+16-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ describe("timeout", () => {
1616
try {
1717
await timeout(updateInterval, maxDuration, action);
1818
} catch (e) {
19-
expect(e).toBe(`Action timed out after ${maxDuration} ms`);
19+
expect(e).toBe(
20+
`Action timed out after ${maxDuration} ms. Last rejection reason was: false.`,
21+
);
2022
}
2123
const end = Date.now();
2224

@@ -37,7 +39,9 @@ describe("timeout", () => {
3739
try {
3840
await timeout(updateInterval, maxDuration, action);
3941
} catch (e) {
40-
expect(e).toEqual(`Action timed out after ${maxDuration} ms`);
42+
expect(e).toEqual(
43+
`Action timed out after ${maxDuration} ms. Didn't receive a result within timeout.`,
44+
);
4145
}
4246
const end = Date.now();
4347

@@ -90,7 +94,7 @@ describe("timeout", () => {
9094
const action = jest.fn(() => {
9195
const interval = Date.now() - start;
9296
return new Promise<boolean>((resolve, reject) =>
93-
interval > delay ? resolve(true) : reject()
97+
interval > delay ? resolve(true) : reject(),
9498
);
9599
});
96100

@@ -114,7 +118,9 @@ describe("timeout", () => {
114118
try {
115119
await timeout(updateInterval, maxDuration, action);
116120
} catch (e) {
117-
expect(e).toEqual(`Action timed out after ${maxDuration} ms`);
121+
expect(e).toEqual(
122+
`Action timed out after ${maxDuration} ms. Didn't receive a result within timeout.`,
123+
);
118124
}
119125
const end = Date.now();
120126

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

139145
// THEN
140-
await expect(SUT).rejects.toBe(`Action timed out after ${maxDuration} ms`);
146+
await expect(SUT).rejects.toBe(
147+
`Action timed out after ${maxDuration} ms. Didn't receive a result within timeout.`,
148+
);
141149
expect(action).toBeCalledTimes(1);
142150
});
143151

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

159167
// THEN
160-
await expect(SUT).rejects.toBe(`Action timed out after ${maxDuration} ms`);
168+
await expect(SUT).rejects.toBe(
169+
`Action timed out after ${maxDuration} ms. Didn't receive a result within timeout.`,
170+
);
161171
expect(action).toBeCalledTimes(1);
162172
await sleep(500);
163173
expect(action).toBeCalledTimes(1);

0 commit comments

Comments
 (0)