adjust sync native package

This commit is contained in:
Nikita Sivukhin
2025-09-24 18:43:50 +04:00
parent 28c9850b57
commit afbfa98a8d
7 changed files with 284 additions and 154 deletions

View File

@@ -1,6 +1,6 @@
import { unlinkSync } from "node:fs";
import { expect, test } from 'vitest'
import { connect, DatabaseRowMutation, DatabaseRowTransformResult } from './promise.js'
import { connect, Database, DatabaseRowMutation, DatabaseRowTransformResult } from './promise.js'
const localeCompare = (a, b) => a.x.localeCompare(b.x);
@@ -12,6 +12,13 @@ function cleanup(path) {
try { unlinkSync(`${path}-wal-revert`) } catch (e) { }
}
test('explicit 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();
expect(await db.prepare("SELECT 1 as x").all()).toEqual([{ x: 1 }]);
})
test('select-after-push', async () => {
{
const db = await connect({ path: ':memory:', url: process.env.VITE_TURSO_DB_URL });