Skip to content

Commit

Permalink
Add tests for bun:sqlite statement iterate
Browse files Browse the repository at this point in the history
  • Loading branch information
Skywalker13 committed Oct 5, 2024
1 parent b5efed5 commit e894668
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/js/bun/sqlite/sqlite.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,24 @@ it("db.query()", () => {
}
})(domjit);

// iterate (no args)
let i;
i = 0;
for (const row of db.query("SELECT * FROM test").iterate()) {
i === 0 && expect(JSON.stringify(row)).toBe(JSON.stringify({ id: 1, name: "Hello" }));
i === 1 && expect(JSON.stringify(row)).toBe(JSON.stringify({ id: 2, name: "World" }));
i++;
}
expect(i).toBe(2);

// iterate (args)
i = 0;
for (const row of db.query("SELECT * FROM test WHERE name = $name").iterate({ $name: "World" })) {
i === 0 && expect(JSON.stringify(row)).toBe(JSON.stringify({ id: 2, name: "World" }));
i++;
}
expect(i).toBe(1);

db.close();

// Check that a closed database doesn't crash
Expand Down

0 comments on commit e894668

Please sign in to comment.