diff --git a/test/database.spec.js b/test/database.spec.js index 17808a9..194c759 100644 --- a/test/database.spec.js +++ b/test/database.spec.js @@ -6,9 +6,11 @@ import { DB } from "../lib/index.js"; describe("DB.query", function () { /** @type {DB} */ let database; + before(function () { database = new DB(1); }); + after(async function () { await database.close(); }); @@ -227,12 +229,15 @@ describe("DB.query", function () { for (const { query, results, fields } of testParameters) { describe(`with ${query}`, function () { let actualResults, actualFields; + before(async function () { [actualResults, actualFields] = await database.query(query); }); + it("returns desired results", function () { assert.deepStrictEqual(actualResults, results); }); + it("returns desired fields", function () { assert.deepStrictEqual( JSON.parse(JSON.stringify(actualFields)), diff --git a/test/mem.spec.js b/test/mem.spec.js index b7ad9d4..9b088dd 100644 --- a/test/mem.spec.js +++ b/test/mem.spec.js @@ -7,24 +7,31 @@ describe("MEM", function () { const value = { hello: "world", }; + before(async function () { mem = await new MEM().connect(); }); + after(async function () { await mem.quit(); }); + describe("set and get test-key", function () { const testKey = "test-key"; + before(async function () { await mem.set(testKey, JSON.stringify(value)); }); + it("returns the written test key", async function () { const userSession = await mem.get(testKey); assert.deepStrictEqual(userSession, JSON.stringify(value)); }); + it("del key", async function () { await mem.del(testKey); }); + it("doesn't return the deleted test key", async function () { const userSession = await mem.get(testKey); assert.notOk(userSession);