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,25 @@
import assert from "node:assert";
import { describe, test } from "node:test";
import { ObjectTree } from "../../src/internal.js";
import scope from "../../src/operations/scope.js";
describe("scope", () => {
test("gets the first defined value from the scope trees", async () => {
const outer = new ObjectTree({
a: 1,
b: 2,
});
const inner = new ObjectTree({
a: 3,
});
inner.parent = outer;
const innerScope = scope(inner);
assert.deepEqual([...(await innerScope.keys())], ["a", "b"]);
// Inner tree has precedence
assert.equal(await innerScope.get("a"), 3);
// If tree doesn't have value, finds value from parent
assert.equal(await innerScope.get("b"), 2);
assert.equal(await innerScope.get("c"), undefined);
assert.deepEqual(innerScope.trees, [inner, outer]);
});
});