diff --git a/src/common/utils/with-error-suppression/with-error-suppression.test.ts b/src/common/utils/with-error-suppression/with-error-suppression.test.ts index dc15762721..db4909fd55 100644 --- a/src/common/utils/with-error-suppression/with-error-suppression.test.ts +++ b/src/common/utils/with-error-suppression/with-error-suppression.test.ts @@ -58,8 +58,8 @@ describe("with-error-suppression", () => { }); describe("given decorated async function", () => { - let decorated: (a: string, b: string) => Promise; - let toBeDecorated: AsyncFnMock; + let decorated: (a: string, b: string) => Promise | Promise; + let toBeDecorated: AsyncFnMock<(a: string, b: string) => number>; beforeEach(() => { toBeDecorated = asyncFn(); @@ -68,7 +68,7 @@ describe("with-error-suppression", () => { }); describe("when called", () => { - let returnValuePromise: Promise; + let returnValuePromise: Promise | Promise; beforeEach(() => { returnValuePromise = decorated("some-parameter", "some-other-parameter"); @@ -92,12 +92,12 @@ describe("with-error-suppression", () => { expect(returnValue).toBeUndefined(); }); - it("when call resolves, resolves with nothing", async () => { - await toBeDecorated.resolve(undefined); + it("when call resolves, resolves with the value", async () => { + await toBeDecorated.resolve(42); const returnValue = await returnValuePromise; - expect(returnValue).toBeUndefined(); + expect(returnValue).toBe(42); }); }); }); diff --git a/src/common/utils/with-error-suppression/with-error-suppression.ts b/src/common/utils/with-error-suppression/with-error-suppression.ts index 73d7e8b64c..657ed13c16 100644 --- a/src/common/utils/with-error-suppression/with-error-suppression.ts +++ b/src/common/utils/with-error-suppression/with-error-suppression.ts @@ -4,8 +4,8 @@ */ import { noop } from "lodash/fp"; -export function withErrorSuppression Promise>(toBeDecorated: TDecorated): (...args: Parameters) => Promise; -export function withErrorSuppression void>(toBeDecorated: TDecorated): (...args: Parameters) => void; +export function withErrorSuppression Promise>(toBeDecorated: TDecorated): (...args: Parameters) => ReturnType | Promise; +export function withErrorSuppression any>(toBeDecorated: TDecorated): (...args: Parameters) => ReturnType | void; export function withErrorSuppression(toBeDecorated: any) { return (...args: any[]) => {