From 7179cf978abc2e9d608a9b13ac7d06c895f205db Mon Sep 17 00:00:00 2001 From: Michael Drury Date: Thu, 3 Mar 2022 23:50:46 +0000 Subject: [PATCH] Updating test case to handle new promise library. --- packages/server/__mocks__/mysql2/promise.ts | 17 +++++++++++++++++ .../server/src/integrations/tests/mysql.spec.js | 8 ++++---- 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 packages/server/__mocks__/mysql2/promise.ts diff --git a/packages/server/__mocks__/mysql2/promise.ts b/packages/server/__mocks__/mysql2/promise.ts new file mode 100644 index 0000000000..8a8fb7fcf0 --- /dev/null +++ b/packages/server/__mocks__/mysql2/promise.ts @@ -0,0 +1,17 @@ +module MySQLMock { + const mysql: any = {} + + const client = { + connect: jest.fn(), + end: jest.fn(), + query: jest.fn(async () => { + return [[]] + }), + } + + mysql.createConnection = jest.fn(async () => { + return client + }) + + module.exports = mysql +} diff --git a/packages/server/src/integrations/tests/mysql.spec.js b/packages/server/src/integrations/tests/mysql.spec.js index 47ca3688f0..8304771d5d 100644 --- a/packages/server/src/integrations/tests/mysql.spec.js +++ b/packages/server/src/integrations/tests/mysql.spec.js @@ -19,7 +19,7 @@ describe("MySQL Integration", () => { await config.integration.create({ sql }) - expect(config.integration.client.query).toHaveBeenCalledWith(sql, {}, expect.any(Function)) + expect(config.integration.client.query).toHaveBeenCalledWith(sql, []) }) it("calls the read method with the correct params", async () => { @@ -27,7 +27,7 @@ describe("MySQL Integration", () => { await config.integration.read({ sql }) - expect(config.integration.client.query).toHaveBeenCalledWith(sql, {}, expect.any(Function)) + expect(config.integration.client.query).toHaveBeenCalledWith(sql, []) }) it("calls the update method with the correct params", async () => { @@ -35,7 +35,7 @@ describe("MySQL Integration", () => { await config.integration.update({ sql }) - expect(config.integration.client.query).toHaveBeenCalledWith(sql, {}, expect.any(Function)) + expect(config.integration.client.query).toHaveBeenCalledWith(sql, []) }) it("calls the delete method with the correct params", async () => { @@ -43,7 +43,7 @@ describe("MySQL Integration", () => { await config.integration.delete({ sql }) - expect(config.integration.client.query).toHaveBeenCalledWith(sql, {}, expect.any(Function)) + expect(config.integration.client.query).toHaveBeenCalledWith(sql, []) }) describe("no rows returned", () => {