import { RunResult, SqlType, Statement, TypedDatabase } from "../../types"; import * as sqlite3 from "sqlite3"; export async function init(): Promise { return; } export class MockDatabase implements TypedDatabase { // eslint-disable-next-line @typescript-eslint/no-empty-function constructor() {} // eslint-disable-next-line @typescript-eslint/no-unused-vars async on(event: string, listener: unknown): Promise { return; } // eslint-disable-next-line @typescript-eslint/no-unused-vars async run(sql: SqlType, ...params: unknown[]): Promise { return { stmt: new Statement(new sqlite3.Statement()), }; } async get( // eslint-disable-next-line @typescript-eslint/no-unused-vars sql: SqlType, // eslint-disable-next-line @typescript-eslint/no-unused-vars ...params: unknown[] ): Promise { return undefined; } async each( sql: SqlType, callback: (err: unknown, row: T) => void ): Promise; async each( sql: SqlType, param1: unknown, callback: (err: unknown, row: T) => void ): Promise; async each( sql: SqlType, param1: unknown, param2: unknown, callback: (err: unknown, row: T) => void ): Promise; async each( sql: SqlType, param1: unknown, param2: unknown, param3: unknown, callback: (err: unknown, row: T) => void ): Promise; // eslint-disable-next-line @typescript-eslint/no-unused-vars async each( sql: SqlType, ...params: unknown[] ): Promise; // eslint-disable-next-line @typescript-eslint/no-unused-vars async each(sql: SqlType, ...callback: unknown[]): Promise { return 0; } // eslint-disable-next-line @typescript-eslint/no-unused-vars async all(sql: SqlType, ...params: unknown[]): Promise { return []; } // eslint-disable-next-line @typescript-eslint/no-unused-vars async exec(sql: SqlType, ...params: unknown[]): Promise { return; } // eslint-disable-next-line @typescript-eslint/no-unused-vars async prepare(sql: SqlType, ...params: unknown[]): Promise { return new Statement(new sqlite3.Statement()); } } export const db: MockDatabase = new MockDatabase(); export { Statement };