budibase/packages/server/__mocks__/pg.js

30 lines
444 B
JavaScript
Raw Normal View History

const pg = {}
2021-05-21 17:02:21 +02:00
const query = jest.fn(() => ({
2021-03-15 17:07:04 +01:00
rows: [
{
a: "string",
b: 1,
},
],
}))
2021-05-21 17:02:21 +02:00
// constructor
function Client() {}
Client.prototype.query = query
2021-03-15 17:07:04 +01:00
Client.prototype.connect = jest.fn()
2021-05-21 17:02:21 +02:00
Client.prototype.release = jest.fn()
function Pool() {}
Pool.prototype.query = query
Pool.prototype.connect = jest.fn(() => {
return new Client()
})
pg.Client = Client
2021-05-21 17:02:21 +02:00
pg.Pool = Pool
pg.queryMock = query
module.exports = pg