commits
tags
import { describe, expect, it } from "vitest";
import type { Step } from "./api";
import type { Schema } from "./schema";
import { outputHandles } from "./handles";
const SCHEMA = {
step_types: [
{ type: "click", category: "interaction", label_sv: "", label_en: "", fields: [] },
{ type: "if", category: "control", label_sv: "", label_en: "", control: "if", fields: [] },
{ type: "loop", category: "control", label_sv: "", label_en: "", control: "loop", fields: [] },
],
condition_kinds: [],
settings: [],
input_fields: [],
close_modes: [],
} as unknown as Schema;
describe("outputHandles", () => {
it("plain node has a single 'out'", () => {
expect(outputHandles(SCHEMA, { type: "click" } as Step)).toEqual(["out"]);
});
it("if node has one case per branch plus else", () => {
const node = { type: "if", branches: [{ condition: { kind: "x" } }, { condition: { kind: "y" } }] } as Step;
expect(outputHandles(SCHEMA, node)).toEqual(["case0", "case1", "else"]);
});
it("if node with no branches still exposes case0 + else", () => {
expect(outputHandles(SCHEMA, { type: "if" } as Step)).toEqual(["case0", "else"]);
});
it("loop node has each + done", () => {
expect(outputHandles(SCHEMA, { type: "loop" } as Step)).toEqual(["each", "done"]);
});
});