2021-11-18 13:05:30 +01:00
|
|
|
module OracleDbMock {
|
|
|
|
// mock execute
|
|
|
|
const execute = jest.fn(() => ({
|
|
|
|
rows: [
|
|
|
|
{
|
|
|
|
a: "string",
|
|
|
|
b: 1,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}))
|
|
|
|
|
|
|
|
const close = jest.fn()
|
|
|
|
|
|
|
|
// mock connection
|
2024-03-19 12:29:19 +01:00
|
|
|
const Connection = () => {}
|
2021-11-18 13:05:30 +01:00
|
|
|
Connection.prototype.execute = execute
|
|
|
|
Connection.prototype.close = close
|
|
|
|
|
|
|
|
// mock oracledb
|
|
|
|
const oracleDb: any = {}
|
|
|
|
oracleDb.getConnection = jest.fn(() => {
|
|
|
|
// @ts-ignore
|
|
|
|
return new Connection()
|
|
|
|
})
|
|
|
|
|
|
|
|
// expose mocks
|
|
|
|
oracleDb.executeMock = execute
|
|
|
|
oracleDb.closeMock = close
|
|
|
|
|
|
|
|
module.exports = oracleDb
|
|
|
|
}
|