1
0

run npm install to generate a package lock

This commit is contained in:
sashinexists
2024-12-07 13:18:31 +11:00
parent e7d08a91b5
commit 23437d228e
2501 changed files with 290663 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
import assert from "node:assert";
import { describe, test } from "node:test";
import SetTree from "../../src/drivers/SetTree.js";
import { ObjectTree } from "../../src/internal.js";
describe("SetTree", () => {
test("can get the keys of the tree", async () => {
const set = new Set(["a", "b", "c"]);
const fixture = new SetTree(set);
assert.deepEqual(Array.from(await fixture.keys()), [0, 1, 2]);
});
test("can get the value for a key", async () => {
const set = new Set(["a", "b", "c"]);
const fixture = new SetTree(set);
const a = await fixture.get(0);
assert.equal(a, "a");
});
test("getting an unsupported key returns undefined", async () => {
const set = new Set(["a", "b", "c"]);
const fixture = new SetTree(set);
assert.equal(await fixture.get(3), undefined);
});
test("getting a null/undefined key throws an exception", async () => {
const set = new Set(["a", "b", "c"]);
const fixture = new SetTree(set);
await assert.rejects(async () => {
await fixture.get(null);
});
await assert.rejects(async () => {
await fixture.get(undefined);
});
});
test("sets parent on subtrees", async () => {
const set = new Set();
set.add(new ObjectTree({}));
const fixture = new SetTree(set);
const subtree = await fixture.get(0);
assert.equal(subtree.parent, fixture);
});
});