Files
sashinexists/node_modules/@weborigami/language/test/runtime/functionResultsMap.test.js
2024-12-07 13:18:31 +11:00

25 lines
792 B
JavaScript

import { ObjectTree, Tree, scope } from "@weborigami/async-tree";
import assert from "node:assert";
import { describe, test } from "node:test";
import functionResultsMap from "../../src/runtime/functionResultsMap.js";
describe("functionResultsMap", () => {
test("get() invokes functions using scope, returns other values as is", async () => {
const parent = new ObjectTree({
message: "Hello",
});
const tree = new ObjectTree({
fn: /** @this {import("@weborigami/types").AsyncTree} */ function () {
return scope(this).get("message");
},
string: "string",
});
tree.parent = parent;
const fixture = functionResultsMap(tree);
assert.deepEqual(await Tree.plain(fixture), {
fn: "Hello",
string: "string",
});
});
});