2021-06-26 00:46:02 +12:00
|
|
|
module PgMock {
|
|
|
|
const pg: any = {}
|
|
|
|
|
|
|
|
const query = jest.fn(() => ({
|
|
|
|
rows: [
|
|
|
|
{
|
|
|
|
a: "string",
|
|
|
|
b: 1,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}))
|
|
|
|
|
2022-01-20 21:17:08 +13:00
|
|
|
// constructor
|
|
|
|
function Client() {}
|
2021-06-26 00:46:02 +12:00
|
|
|
|
|
|
|
Client.prototype.query = query
|
2022-05-21 05:08:48 +12:00
|
|
|
Client.prototype.end = jest.fn(cb => {
|
|
|
|
if (cb) cb()
|
|
|
|
})
|
2021-06-26 00:46:02 +12:00
|
|
|
Client.prototype.connect = jest.fn()
|
|
|
|
Client.prototype.release = jest.fn()
|
|
|
|
|
2021-10-28 05:21:29 +13:00
|
|
|
const on = jest.fn()
|
2021-06-26 00:46:02 +12:00
|
|
|
|
|
|
|
pg.Client = Client
|
|
|
|
pg.queryMock = query
|
2021-10-28 05:21:29 +13:00
|
|
|
pg.on = on
|
2021-06-26 00:46:02 +12:00
|
|
|
|
|
|
|
module.exports = pg
|
|
|
|
}
|