From a84b52238c08940c6bf478c110f9e991678a107a Mon Sep 17 00:00:00 2001 From: Tom Date: Thu, 1 Jul 2021 11:40:48 +0100 Subject: [PATCH] Added tests for new reindexing behaviour --- tests/CRUD.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/CRUD.js b/tests/CRUD.js index 20eed02..73c4c76 100644 --- a/tests/CRUD.js +++ b/tests/CRUD.js @@ -131,8 +131,28 @@ describe("StormDB", function() { }); }); - describe(".delete()", function() { - it("should successfully remove value from database", function() { + describe(".delete()", function () { + it("should successfully delete from list without reindexing", function () { + const engine = new StormDB.localFileEngine(exampleDBPath); + const db = new StormDB(engine); + + db.get("test-list").get(1).delete(); + + let value = db.get("test-list").get(1).value(); + assert.strictEqual(value, undefined); + }); + + it("should successfully delete from with reindexing", function () { + const engine = new StormDB.localFileEngine(exampleDBPath); + const db = new StormDB(engine); + + db.get("test-list").get(1).delete(true); + + let value = db.get("test-list").get(1).value(); + assert.strictEqual(value, 3); + }); + + it("should successfully remove value from database", function () { const engine = new StormDB.localFileEngine(exampleDBPath); const db = new StormDB(engine);