diff --git a/packages/backend-core/src/tests/utils.spec.js b/packages/backend-core/src/tests/utils.spec.js index a1415a21b9..bb0f24fad6 100644 --- a/packages/backend-core/src/tests/utils.spec.js +++ b/packages/backend-core/src/tests/utils.spec.js @@ -7,7 +7,7 @@ describe("utils", () => { it("should call platform logout", async () => { const ctx = structures.koa.newContext() await utils.platformLogout({ ctx, userId: "test" }) - expect(events.auth.logout.mock.calls.length).toBe(1) + expect(events.auth.logout).toBeCalledTimes(1) }) }) }) \ No newline at end of file diff --git a/packages/server/src/api/routes/tests/application.spec.js b/packages/server/src/api/routes/tests/application.spec.js index 4bf6aa8282..a0fca7a6c8 100644 --- a/packages/server/src/api/routes/tests/application.spec.js +++ b/packages/server/src/api/routes/tests/application.spec.js @@ -41,7 +41,7 @@ describe("/applications", () => { .expect("Content-Type", /json/) .expect(200) expect(res.body._id).toBeDefined() - expect(events.app.created.mock.calls.length).toBe(1) + expect(events.app.created).toBeCalledTimes(1) }) it("creates app from template", async () => { @@ -55,8 +55,8 @@ describe("/applications", () => { .expect("Content-Type", /json/) .expect(200) expect(res.body._id).toBeDefined() - expect(events.app.created.mock.calls.length).toBe(1) - expect(events.app.templateImported.mock.calls.length).toBe(1) + expect(events.app.created).toBeCalledTimes(1) + expect(events.app.templateImported).toBeCalledTimes(1) }) @@ -70,8 +70,8 @@ describe("/applications", () => { .expect("Content-Type", /json/) .expect(200) expect(res.body._id).toBeDefined() - expect(events.app.created.mock.calls.length).toBe(1) - expect(events.app.fileImported.mock.calls.length).toBe(1) + expect(events.app.created).toBeCalledTimes(1) + expect(events.app.fileImported).toBeCalledTimes(1) }) it("should apply authorization to endpoint", async () => { @@ -135,7 +135,7 @@ describe("/applications", () => { .expect("Content-Type", /json/) .expect(200) expect(res.body.rev).toBeDefined() - expect(events.app.updated.mock.calls.length).toBe(1) + expect(events.app.updated).toBeCalledTimes(1) }) }) @@ -148,7 +148,7 @@ describe("/applications", () => { .set(config.defaultHeaders()) .expect("Content-Type", /json/) .expect(200) - expect(events.app.deleted.mock.calls.length).toBe(1) + expect(events.app.deleted).toBeCalledTimes(1) }) it("should unpublish app", async () => { @@ -159,7 +159,7 @@ describe("/applications", () => { .set(config.defaultHeaders()) .expect("Content-Type", /json/) .expect(200) - expect(events.app.unpublished.mock.calls.length).toBe(1) + expect(events.app.unpublished).toBeCalledTimes(1) }) }) @@ -171,7 +171,7 @@ describe("/applications", () => { .set(config.defaultHeaders()) .expect("Content-Type", /json/) .expect(200) - expect(events.app.versionUpdated.mock.calls.length).toBe(1) + expect(events.app.versionUpdated).toBeCalledTimes(1) }) it("should be able to revert the app client library version", async () => { // We need to first update the version so that we can then revert @@ -185,7 +185,7 @@ describe("/applications", () => { .set(config.defaultHeaders()) .expect("Content-Type", /json/) .expect(200) - expect(events.app.versionReverted.mock.calls.length).toBe(1) + expect(events.app.versionReverted).toBeCalledTimes(1) }) }) diff --git a/packages/server/src/api/routes/tests/datasource.spec.js b/packages/server/src/api/routes/tests/datasource.spec.js index bc7e6cf4af..520a17015c 100644 --- a/packages/server/src/api/routes/tests/datasource.spec.js +++ b/packages/server/src/api/routes/tests/datasource.spec.js @@ -31,7 +31,7 @@ describe("/datasources", () => { expect(res.body.datasource.name).toEqual("Test") expect(res.body.errors).toBeUndefined() - expect(events.datasource.created.mock.calls.length).toBe(1) + expect(events.datasource.created).toBeCalledTimes(1) }) }) @@ -47,7 +47,7 @@ describe("/datasources", () => { expect(res.body.datasource.name).toEqual("Updated Test") expect(res.body.errors).toBeUndefined() - expect(events.datasource.updated.mock.calls.length).toBe(1) + expect(events.datasource.updated).toBeCalledTimes(1) }) describe("dynamic variables", () => { @@ -164,7 +164,7 @@ describe("/datasources", () => { .expect(200) expect(res.body.length).toEqual(1) - expect(events.datasource.deleted.mock.calls.length).toBe(1) + expect(events.datasource.deleted).toBeCalledTimes(1) }) it("should apply authorization to endpoint", async () => { diff --git a/packages/worker/src/api/routes/tests/auth.spec.js b/packages/worker/src/api/routes/tests/auth.spec.js index 1c33ea750a..0d3b228827 100644 --- a/packages/worker/src/api/routes/tests/auth.spec.js +++ b/packages/worker/src/api/routes/tests/auth.spec.js @@ -41,7 +41,7 @@ describe("/api/global/auth", () => { .post("/api/global/auth/logout") .set(config.defaultHeaders()) .expect(200) - expect(events.auth.logout.mock.calls.length).toBe(1) + expect(events.auth.logout).toBeCalledTimes(1) }) it("should be able to generate password reset email", async () => {