Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/packages/db/src/automation-graph.test.ts
T

22 lines
1.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
AUTOMATION_CONDITION_BRANCHES_CONFIG_KEY,
automationConditionBranchForParent,
automationConditionBranches,
withAutomationConditionBranch,
} from "./automation-graph.js";
describe("automation condition edge metadata", () => {
it("defaults legacy condition edges to the true branch", () => {
expect(automationConditionBranchForParent({}, "condition")).toBe("true");
});
it("adds, reads and removes branch metadata without changing action config", () => {
const configured = withAutomationConditionBranch({ titel: "Nachfassen" }, "condition", "false");
expect(configured).toEqual({ titel: "Nachfassen", [AUTOMATION_CONDITION_BRANCHES_CONFIG_KEY]: { condition: "false" } });
expect(automationConditionBranches(configured)).toEqual({ condition: "false" });
expect(automationConditionBranchForParent(configured, "condition")).toBe("false");
expect(withAutomationConditionBranch(configured, "condition", null)).toEqual({ titel: "Nachfassen" });
});
});