From 8b8c923541b48157f7f65ff2d7a14fdc6f9e5051 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Wed, 27 Oct 2021 17:21:29 +0100 Subject: [PATCH] Update tests --- packages/server/__mocks__/pg.ts | 3 +++ packages/server/src/integrations/tests/postgres.spec.js | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/packages/server/__mocks__/pg.ts b/packages/server/__mocks__/pg.ts index 0ec823ea39..ba7803f9a8 100644 --- a/packages/server/__mocks__/pg.ts +++ b/packages/server/__mocks__/pg.ts @@ -21,15 +21,18 @@ module PgMock { function Pool() { } + const on = jest.fn() Pool.prototype.query = query Pool.prototype.connect = jest.fn(() => { // @ts-ignore return new Client() }) + Pool.prototype.on = on pg.Client = Client pg.Pool = Pool pg.queryMock = query + pg.on = on module.exports = pg } diff --git a/packages/server/src/integrations/tests/postgres.spec.js b/packages/server/src/integrations/tests/postgres.spec.js index 4ce5f12e96..5c0d086ce0 100644 --- a/packages/server/src/integrations/tests/postgres.spec.js +++ b/packages/server/src/integrations/tests/postgres.spec.js @@ -15,6 +15,10 @@ describe("Postgres Integration", () => { config = new TestConfiguration() }) + it("calls the connection callback", async () => { + expect(pg.on).toHaveBeenCalledWith('connect', expect.anything()) + }) + it("calls the create method with the correct params", async () => { const sql = "insert into users (name, age) values ('Joe', 123);" await config.integration.create({