run npm install to generate a package lock
This commit is contained in:
25
node_modules/@weborigami/async-tree/test/operations/scope.test.js
generated
vendored
Normal file
25
node_modules/@weborigami/async-tree/test/operations/scope.test.js
generated
vendored
Normal 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]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user