Browse Source

Update tests

master
Rory Powell 5 years ago
parent
commit
8b8c923541
  1. 3
      packages/server/__mocks__/pg.ts
  2. 4
      packages/server/src/integrations/tests/postgres.spec.js

3
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
}

4
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({

Loading…
Cancel
Save