bindings/javascript: Fix Statement.get() implementation

This commit is contained in:
Pekka Enberg 2025-03-28 10:52:11 +02:00
parent 7348eb0aa1
commit 94262e4660
3 changed files with 29 additions and 9 deletions

View file

@ -7,11 +7,21 @@ test("Open in-memory database", async (t) => {
t.is(db.memory, true);
});
test("Statement.get()", async (t) => {
test("Statement.get() returns data", async (t) => {
const [db] = await connect(":memory:");
const stmt = db.prepare("SELECT 1");
const result = stmt.get();
t.is(result["1"], 1);
const result2 = stmt.get();
t.is(result2["1"], 1);
});
test("Statement.get() returns null when no data", async (t) => {
const [db] = await connect(":memory:");
const stmt = db.prepare("SELECT 1 WHERE 1 = 2");
const result = stmt.get();
t.is(result, undefined);
});
const connect = async (path) => {