Skip to content

Commit

Permalink
Update assert function (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
tilfin authored Oct 29, 2023
1 parent 8e83dc8 commit 4df1522
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/extension/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import * as externalTest from "./tests/external.test.js";
import * as findTargetProfilesTest from "./tests/find_target_profiles.test.js";
import * as updateProfileTableTest from "./tests/update_profiles.test.js";

self.assert = function (actual, expected, message = '') {
const actualStr = JSON.stringify(actual);
const expectedStr = JSON.stringify(expected);
if (expectedStr !== actualStr) {
throw new Error(`${message} expected ${expectedStr} but got ${actualStr}`);
}
self.assert = function deepEqual(actual, expected, message = '') {
Object.entries(actual).forEach(([key, value]) => {
if (typeof value === 'object') {
deepEqual(value, expected[key]);
} else if (expected[key] !== value) {
throw new Error(`${message} expected ${expected[key]} but got ${value}`);
}
});
}

self.assertNever = function () {
Expand Down

0 comments on commit 4df1522

Please sign in to comment.