fix tests

This commit is contained in:
Nikita Sivukhin
2025-09-30 20:45:00 +04:00
parent 4772c0406e
commit 18e8c037e9
3 changed files with 9 additions and 6 deletions

View File

@@ -12,10 +12,11 @@ function cleanup(path) {
try { unlinkSync(`${path}-wal-revert`) } catch (e) { }
}
test('explicit connect', async () => {
test('implicit connect', async () => {
const db = new Database({ path: ':memory:', url: process.env.VITE_TURSO_DB_URL });
expect(() => db.prepare("SELECT 1")).toThrowError(/database must be connected/g);
await db.connect();
const defer = db.prepare("SELECT * FROM t");
await expect(async () => await defer.all()).rejects.toThrowError(/no such table: t/);
expect(() => db.prepare("SELECT * FROM t")).toThrowError(/no such table: t/);
expect(await db.prepare("SELECT 1 as x").all()).toEqual([{ x: 1 }]);
})