From aa32655cbeb7c1e1a528aade0bbc5f69eab4ada6 Mon Sep 17 00:00:00 2001 From: Janne Savolainen Date: Wed, 18 May 2022 08:43:02 +0300 Subject: [PATCH] Make test more strict Co-authored-by: Mikko Aspiala Signed-off-by: Janne Savolainen --- src/common/runnable/run-many-for.test.ts | 11 +++++++---- src/common/runnable/run-many-sync-for.test.ts | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/common/runnable/run-many-for.test.ts b/src/common/runnable/run-many-for.test.ts index 997b913b25..e281c6cb44 100644 --- a/src/common/runnable/run-many-for.test.ts +++ b/src/common/runnable/run-many-for.test.ts @@ -17,7 +17,7 @@ import { getPromiseStatus } from "../test-utils/get-promise-status"; describe("runManyFor", () => { describe("given no hierarchy, when running many", () => { - let runMock: AsyncFnMock<() => Promise>; + let runMock: AsyncFnMock<(...args: unknown[]) => Promise>; let actualPromise: Promise; beforeEach(() => { @@ -31,13 +31,13 @@ describe("runManyFor", () => { const someInjectable = getInjectable({ id: "some-injectable", - instantiate: () => ({ run: runMock }), + instantiate: () => ({ run: () => runMock("some-call") }), injectionToken: someInjectionTokenForRunnables, }); const someOtherInjectable = getInjectable({ id: "some-other-injectable", - instantiate: () => ({ run: runMock }), + instantiate: () => ({ run: () => runMock("some-other-call") }), injectionToken: someInjectionTokenForRunnables, }); @@ -49,7 +49,10 @@ describe("runManyFor", () => { }); it("runs all runnables at the same time", () => { - expect(runMock).toHaveBeenCalledTimes(2); + expect(runMock.mock.calls).toEqual([ + ["some-call"], + ["some-other-call"], + ]); }); it("does not resolve yet", async () => { diff --git a/src/common/runnable/run-many-sync-for.test.ts b/src/common/runnable/run-many-sync-for.test.ts index f115c33265..4e28362724 100644 --- a/src/common/runnable/run-many-sync-for.test.ts +++ b/src/common/runnable/run-many-sync-for.test.ts @@ -27,13 +27,13 @@ describe("runManySyncFor", () => { const someInjectable = getInjectable({ id: "some-injectable", - instantiate: () => ({ run: runMock }), + instantiate: () => ({ run: () => runMock("some-call") }), injectionToken: someInjectionTokenForRunnables, }); const someOtherInjectable = getInjectable({ id: "some-other-injectable", - instantiate: () => ({ run: runMock }), + instantiate: () => ({ run: () => runMock("some-other-call") }), injectionToken: someInjectionTokenForRunnables, }); @@ -45,7 +45,10 @@ describe("runManySyncFor", () => { }); it("runs all runnables at the same time", () => { - expect(runMock).toHaveBeenCalledTimes(2); + expect(runMock.mock.calls).toEqual([ + ["some-call"], + ["some-other-call"], + ]); }); });