mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
Updated the Bun and Node SQLite connection implementations to support additional configuration options, including `onCreateConnection`. Introduced tests for connection creation to validate database instance types and ensure proper callback execution. Improved type exports for better integration with existing code.
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import { connectionTestSuite } from "data/connection/connection-test-suite";
|
|
import { bunSqlite } from "./BunSqliteConnection";
|
|
import { bunTestRunner } from "adapter/bun/test";
|
|
import { describe, test, mock, expect } from "bun:test";
|
|
import { Database } from "bun:sqlite";
|
|
import { GenericSqliteConnection } from "data/connection/sqlite/GenericSqliteConnection";
|
|
|
|
describe("BunSqliteConnection", () => {
|
|
connectionTestSuite(bunTestRunner, {
|
|
makeConnection: () => ({
|
|
connection: bunSqlite({ database: new Database(":memory:") }),
|
|
dispose: async () => {},
|
|
}),
|
|
rawDialectDetails: [],
|
|
});
|
|
|
|
test("onCreateConnection", async () => {
|
|
const called = mock(() => null);
|
|
|
|
const conn = bunSqlite({
|
|
onCreateConnection: (db) => {
|
|
expect(db).toBeInstanceOf(Database);
|
|
called();
|
|
},
|
|
});
|
|
await conn.ping();
|
|
|
|
expect(conn).toBeInstanceOf(GenericSqliteConnection);
|
|
expect(conn.db).toBeInstanceOf(Database);
|
|
expect(called).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|