Skip to content

Commit 77967bf

Browse files
committed
(#205) Applied refactoring proposed in review
1 parent c7642af commit 77967bf

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

lib/util/poll-action.function.spec.ts

+4-10
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,10 @@ describe("poll-action", () => {
130130
});
131131

132132
// WHEN
133-
try {
134-
await timeout(updateInterval, maxDuration, action);
135-
} catch (e) {
136-
expect(e).toEqual(`Action timed out after ${maxDuration} ms`);
137-
}
133+
const SUT = () => timeout(updateInterval, maxDuration, action);
138134

139135
// THEN
136+
await expect(SUT).rejects.toBe(`Action timed out after ${maxDuration} ms`);
140137
expect(action).toBeCalledTimes(1);
141138
});
142139

@@ -153,13 +150,10 @@ describe("poll-action", () => {
153150
});
154151

155152
// WHEN
156-
try {
157-
await timeout(updateInterval, maxDuration, action);
158-
} catch (e) {
159-
expect(e).toBe(`Action timed out after ${maxDuration} ms`);
160-
}
153+
const SUT = () => timeout(updateInterval, maxDuration, action);
161154

162155
// THEN
156+
await expect(SUT).rejects.toBe(`Action timed out after ${maxDuration} ms`);
163157
expect(action).toBeCalledTimes(1);
164158
setTimeout(() => {
165159
expect(action).toBeCalledTimes(1);

0 commit comments

Comments
 (0)