1
0
Fork 0
mirror of synced 2024-07-04 14:01:27 +12:00
budibase/packages/server/__mocks__/pg.js

30 lines
444 B
JavaScript
Raw Normal View History

const pg = {}
2021-05-22 03:02:21 +12:00
const query = jest.fn(() => ({
2021-03-16 05:07:04 +13:00
rows: [
{
a: "string",
b: 1,
},
],
}))
2021-05-22 03:02:21 +12:00
// constructor
function Client() {}
Client.prototype.query = query
2021-03-16 05:07:04 +13:00
Client.prototype.connect = jest.fn()
2021-05-22 03:02:21 +12: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-22 03:02:21 +12:00
pg.Pool = Pool
pg.queryMock = query
module.exports = pg