Skip to content

Commit

Permalink
Phased out deprecated assert methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom committed Jan 21, 2021
1 parent 4b6cfc4 commit 85c96a9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
38 changes: 19 additions & 19 deletions tests/CRUD.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ describe("StormDB", function() {
const db = new StormDB(engine);

let value = db.get("test-string").value();
assert.equal(value, "string");
assert.strictEqual(value, "string");
});

it("should successfully get values with multiple property accessors", function() {
const engine = new StormDB.localFileEngine(exampleDBPath);
const db = new StormDB(engine);

let value = db.get("test-obj.nested-key").value();
assert.equal(value, "nested-value");
assert.strictEqual(value, "nested-value");
});
});

Expand All @@ -42,7 +42,7 @@ describe("StormDB", function() {
db.get("test-string").set("changed");

let value = db.get("test-string").value();
assert.equal(value, "changed");
assert.strictEqual(value, "changed");
});

it("should successfully set value in database", function() {
Expand All @@ -52,7 +52,7 @@ describe("StormDB", function() {
db.get("newValue").set("data");

let value = db.get("newValue").value();
assert.equal(value, "data");
assert.strictEqual(value, "data");
});

it("should successfully set nested values with multiple property accessors", function() {
Expand All @@ -65,7 +65,7 @@ describe("StormDB", function() {
.get("one")
.get("two")
.value();
assert.equal(value, "test");
assert.strictEqual(value, "test");
});

it("should successfully set on nested object", function() {
Expand All @@ -78,7 +78,7 @@ describe("StormDB", function() {
.get("test-obj")
.get("data")
.value();
assert.equal(value, "test");
assert.strictEqual(value, "test");
});

describe("setting key-value pair", function() {
Expand All @@ -89,7 +89,7 @@ describe("StormDB", function() {
db.set("newAttribute", "testing");

let value = db.get("newAttribute").value();
assert.equal(value, "testing");
assert.strictEqual(value, "testing");
});

it("should successfully set key-value pair with shorthand syntax", function() {
Expand All @@ -102,7 +102,7 @@ describe("StormDB", function() {
.get("one")
.get("two")
.value();
assert.equal(value, "testing");
assert.strictEqual(value, "testing");
});

it("should be able to use non-strings as key", function() {
Expand All @@ -112,7 +112,7 @@ describe("StormDB", function() {
db.set(1, "testing");

let value = db.get(1).value();
assert.equal(value, "testing");
assert.strictEqual(value, "testing");
});
});
});
Expand All @@ -125,7 +125,7 @@ describe("StormDB", function() {
db.get("test-string").delete();

let value = db.get("test-string").value();
assert.equal(value, undefined);
assert.strictEqual(value, undefined);
});

it("should successfully remove nested values", function() {
Expand All @@ -140,7 +140,7 @@ describe("StormDB", function() {
.get("test-obj")
.get("nested-key")
.value();
assert.equal(value, undefined);
assert.strictEqual(value, undefined);
});
});

Expand All @@ -160,7 +160,7 @@ describe("StormDB", function() {
const db2 = new StormDB(engine2);

let value = db2.get("newValue").value();
assert.equal(value, "value");
assert.strictEqual(value, "value");

deleteFile("tempDB.stormdb");
});
Expand Down Expand Up @@ -201,7 +201,7 @@ describe("StormDB", function() {
db.get("test-list").map(x => x ** 2);

let updatedList = db.get("test-list").value();
assert.deepEqual(updatedList, [1, 4, 9, 16, 25]);
assert.deepStrictEqual(updatedList, [1, 4, 9, 16, 25]);
});

it("should refuse to map a non-array", function() {
Expand Down Expand Up @@ -237,7 +237,7 @@ describe("StormDB", function() {
db.get("test-list").sort((a, b) => b - a);

let updatedList = db.get("test-list").value();
assert.deepEqual(updatedList, [5, 4, 3, 2, 1]);
assert.deepStrictEqual(updatedList, [5, 4, 3, 2, 1]);
});

it("should refuse to sort a non-array", function() {
Expand Down Expand Up @@ -275,7 +275,7 @@ describe("StormDB", function() {
);

let updatedList = db.get("test-list").value();
assert.deepEqual(updatedList, 15);
assert.deepStrictEqual(updatedList, 15);
});

it("should refuse to reduce a non-array", function() {
Expand Down Expand Up @@ -313,7 +313,7 @@ describe("StormDB", function() {
db.get("test-list").filter(i => i > 3);

let updatedList = db.get("test-list").value();
assert.deepEqual(updatedList, [4, 5]);
assert.deepStrictEqual(updatedList, [4, 5]);
});

it("should refuse to filter using non-function", function() {
Expand Down Expand Up @@ -350,7 +350,7 @@ describe("StormDB", function() {
db.default({ defaulted: "defaultString" });

let defaultedKey = db.get("defaulted").value();
assert.equal(defaultedKey, "defaultString");
assert.strictEqual(defaultedKey, "defaultString");
});

it("default value shouldn't be used with non-empty db", function() {
Expand All @@ -362,7 +362,7 @@ describe("StormDB", function() {

let defaultedKey = db.get("defaulted").value();
// if default value not used, key should be undefined in db
assert.equal(defaultedKey, undefined);
assert.strictEqual(defaultedKey, undefined);
});
});

Expand All @@ -375,7 +375,7 @@ describe("StormDB", function() {
.get("test-list")
.length()
.value();
assert.equal(length, 5);
assert.strictEqual(length, 5);
});
});
});
10 changes: 5 additions & 5 deletions tests/browserEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("Browser Engine", function() {
const db = new StormDB(engine);

let value = db.get("key").value();
assert.equal(value, "value");
assert.strictEqual(value, "value");
});

it("should create empty database if it doesn't exist yet", function() {
Expand All @@ -35,7 +35,7 @@ describe("Browser Engine", function() {
const db = new StormDB(engine);

let value = db.value();
assert.deepEqual(value, {});
assert.deepStrictEqual(value, {});
});

it("should successfully write data", function() {
Expand All @@ -51,7 +51,7 @@ describe("Browser Engine", function() {

// extract updated data
let savedValue = JSON.parse(localStorage.data.db)["key"];
assert.equal(savedValue, "newValue");
assert.strictEqual(savedValue, "newValue");
});

it("should throw error if trying to read incorrect data", function() {
Expand Down Expand Up @@ -79,7 +79,7 @@ describe("Browser Engine", function() {
const db = new StormDB(engine);

let value = db.value();
assert.equal(value, "deserialized data");
assert.strictEqual(value, "deserialized data");
});

it("should utilise custom serialize function", function() {
Expand All @@ -95,6 +95,6 @@ describe("Browser Engine", function() {
db.save();

let savedData = localStorage.data.db;
assert.equal(savedData, "serialized data");
assert.strictEqual(savedData, "serialized data");
});
});
8 changes: 4 additions & 4 deletions tests/localEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("Local Engine", function() {
const db = new StormDB(engine);

let value = db.value();
assert.equal(value, "deserialized data");
assert.strictEqual(value, "deserialized data");
});

it("should utilise custom serialize function", function() {
Expand All @@ -36,8 +36,8 @@ describe("Local Engine", function() {

db.save();

let savedData = fs.readFileSync("tempDB.stormdb");
assert.equal(savedData, "serialized data");
let savedData = fs.readFileSync("tempDB.stormdb", 'utf8');
assert.strictEqual(savedData, "serialized data");

deleteFile("tempDB.stormdb");
});
Expand All @@ -57,7 +57,7 @@ describe("Local Engine", function() {
const db = new StormDB(engine);

let dbValue = db.value();
assert.deepEqual(dbValue, {});
assert.deepStrictEqual(dbValue, {});
});

describe("async engine option enabled", function() {
Expand Down

0 comments on commit 85c96a9

Please sign in to comment.