Skip to content

Commit

Permalink
Merge pull request #7 from drazisil:drazisil/issue6
Browse files Browse the repository at this point in the history
Fix failing getTable test
  • Loading branch information
drazisil committed Mar 17, 2024
2 parents 5efce18 + e108b15 commit 8e74755
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions test/getTable.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import assert from "node:assert";
import { describe, it } from "node:test";
// eslint-disable-next-line no-unused-vars
import { getTable, Types } from "../index.js";
import VerbDB from "../lib/database.js";

describe("getTable()", () => {
it("when called with a table that does not exist, should return a DBResult object, with an status set to 404, and an empty result key", () => {
Expand All @@ -11,7 +12,7 @@ describe("getTable()", () => {
const expected = {
status: 404,
statusText: "Table Not Found",
resultCount: 0,
resultCount: 0,
result: [],
};

Expand All @@ -22,28 +23,38 @@ describe("getTable()", () => {
assert.deepStrictEqual(result, expected);
});

it("when called with a table that exists, should return a DBResult object, with an status set to 200, and a result key with the table object", () => {
// Arrange
const table = "users";
/** @type {Types.DBResult} */
const expected = {
status: 200,
statusText: "OK",
result: {
name: "users",
columns: ["id", "name", "email"],
rows: [
it("when called with a table that exists, should return a DBResult object, with an status set to 200, and a result key with the table object", () => {
// Arrange
const table = "users";
/** @type {Types.DBResult} */
const expected = {
status: 200,
statusText: "OK",
resultCount: 2,
result: {
name: "users",
columns: ["id", "name", "email"],
rows: [
{ id: 1, name: "Alice", email: "" },
{ id: 2, name: "Bob", email: "" },
],
primaryKey: "id",
},
};
VerbDB.tables.set("users", {
name: "users",
columns: ["id", "name", "email"],
rows: [
{ id: 1, name: "Alice", email: "" },
{ id: 2, name: "Bob", email: "" },
],
primaryKey: "id",
},
};
],
primaryKey: "id",
});

// Act
const result = getTable(table);
// Act
const result = getTable(table);

// Assert
assert.deepStrictEqual(result, expected);
});
// Assert
assert.deepStrictEqual(result, expected);
});
});

0 comments on commit 8e74755

Please sign in to comment.