This commit is contained in:
Endeavorance 2025-01-01 12:18:54 -05:00
parent 13c3d86a10
commit 20ac2da081
6 changed files with 47 additions and 10 deletions

View file

@ -138,6 +138,22 @@ test(".insertPartial() inserts a partial row", () => {
});
});
test(".insertWithout() inserts a partial row with type safety", () => {
const table = makeTestTable();
table.insertWithout<"user_id">({
name: "Jack",
});
const lookup = table.db.prepare<UserWithID, string>(
`SELECT * FROM ${table} WHERE name = ?`,
);
const found = lookup.get("Jack");
expect(found).toEqual({
user_id: 1,
name: "Jack",
});
});
test(".count() gets the current number of rows in the table", () => {
const table = makeTestTable();
table.insertPartial({ name: "Jack" });
@ -167,6 +183,12 @@ test(".findAll() returns the full table", () => {
expect(allUsers[2]).toEqual({ user_id: 3, name: "Sayid" });
});
test(".query() returns a prepared statement for the table", () => {
const table = makeTestTable();
const query = table.query("SELECT * FROM Users WHERE name = ?");
expect(query).toBeDefined();
});
test(".findOneWhere() returns a row based on basic criteria", () => {
const table = makeTestTable();
table.insertPartial({ name: "Jack" });