import { GraphConfigData } from "@logicflow/core"; import { TestData } from "../type"; import LogicDataToTestData from "../LogicData_TestData"; import { expect, test } from "vitest"; import parse from '../parse'; const raw: GraphConfigData = { "nodes": [{ "id": "43a09a58-23af-4dfd-8416-bff01b8fe9b9", "type": "ID", "x": 220, "y": 280, "properties": { "name": "n76", "nodeId": "n76", "id": "43a09a58-23af-4dfd-8416-bff01b8fe9b9" } }, { "id": "4e499053-d199-49c6-b3cf-0865e126185f", "type": "ID", "x": 620, "y": 140, "properties": { "name": "n78", "nodeId": "n78", "id": "4e499053-d199-49c6-b3cf-0865e126185f" } }, { "id": "72094602-168b-4a01-a954-e6bdd82f4e65", "type": "ID", "x": 680, "y": 240, "properties": { "name": "n79", "nodeId": "n79", "id": "72094602-168b-4a01-a954-e6bdd82f4e65" } }, { "id": "68eb5508-db0e-4361-95f9-03ff5011ebad", "type": "ID", "x": 680, "y": 360, "properties": { "name": "n80", "nodeId": "n80", "id": "68eb5508-db0e-4361-95f9-03ff5011ebad" } }, { "id": "1750305e-95ad-481d-ba3c-7eccb639bcb3", "type": "ID", "x": 620, "y": 460, "properties": { "name": "n81", "nodeId": "n81", "id": "1750305e-95ad-481d-ba3c-7eccb639bcb3" } }, { "id": "dbc1cb70-de70-440d-9cf2-eda21dd4361d", "type": "ID", "x": 920, "y": 300, "properties": { "name": "n84", "nodeId": "n84", "id": "dbc1cb70-de70-440d-9cf2-eda21dd4361d" } }, { "id": "1ab79a26-d972-4af7-aca9-f9e705d382dc", "type": "ID", "x": 1120, "y": 300, "properties": { "name": "n85", "nodeId": "n85", "id": "1ab79a26-d972-4af7-aca9-f9e705d382dc" } }, { "id": "6e96f83b-9511-46cc-aa72-f3a2c095c5c0", "type": "ID", "x": 400, "y": 280, "properties": { "name": "n86", "nodeId": "n86", "id": "6e96f83b-9511-46cc-aa72-f3a2c095c5c0" } }], "edges": [{ "id": "24143dfb-50ae-4f6a-a9db-3852501657b4", "type": "polyline", "sourceNodeId": "4e499053-d199-49c6-b3cf-0865e126185f", "targetNodeId": "1ab79a26-d972-4af7-aca9-f9e705d382dc", "startPoint": { "x": 665, "y": 140 }, "endPoint": { "x": 1120, "y": 270 }, "properties": {}, "pointsList": [{ "x": 665, "y": 140 }, { "x": 695, "y": 140 }, { "x": 695, "y": 139 }, { "x": 1120, "y": 139 }, { "x": 1120, "y": 270 }] }, { "id": "0466a7c3-385e-4a52-967c-0973f2bdebac", "type": "polyline", "sourceNodeId": "1750305e-95ad-481d-ba3c-7eccb639bcb3", "targetNodeId": "1ab79a26-d972-4af7-aca9-f9e705d382dc", "startPoint": { "x": 665, "y": 460 }, "endPoint": { "x": 1120, "y": 330 }, "properties": {}, "pointsList": [{ "x": 665, "y": 460 }, { "x": 1120, "y": 460 }, { "x": 1120, "y": 330 }] }, { "id": "3015074f-6c14-43ce-b327-1a2ca7f6ab05", "type": "polyline", "sourceNodeId": "72094602-168b-4a01-a954-e6bdd82f4e65", "targetNodeId": "dbc1cb70-de70-440d-9cf2-eda21dd4361d", "startPoint": { "x": 725, "y": 240 }, "endPoint": { "x": 875, "y": 299 }, "properties": {}, "pointsList": [{ "x": 725, "y": 240 }, { "x": 800, "y": 240 }, { "x": 800, "y": 299 }, { "x": 875, "y": 299 }] }, { "id": "b76d1e9e-74d1-4f1f-b7a7-6fb671e5ac29", "type": "polyline", "sourceNodeId": "68eb5508-db0e-4361-95f9-03ff5011ebad", "targetNodeId": "dbc1cb70-de70-440d-9cf2-eda21dd4361d", "startPoint": { "x": 725, "y": 360 }, "endPoint": { "x": 875, "y": 300 }, "properties": {}, "pointsList": [{ "x": 725, "y": 360 }, { "x": 800, "y": 360 }, { "x": 800, "y": 300 }, { "x": 875, "y": 300 }] }, { "id": "18fb2517-6182-4593-8235-b817aa945bda", "type": "polyline", "sourceNodeId": "43a09a58-23af-4dfd-8416-bff01b8fe9b9", "targetNodeId": "6e96f83b-9511-46cc-aa72-f3a2c095c5c0", "startPoint": { "x": 265, "y": 280 }, "endPoint": { "x": 355, "y": 280 }, "properties": {}, "pointsList": [{ "x": 265, "y": 280 }, { "x": 355, "y": 280 }] }, { "id": "382ac78c-8201-416f-8fbc-2ce32d7152fc", "type": "polyline", "sourceNodeId": "6e96f83b-9511-46cc-aa72-f3a2c095c5c0", "targetNodeId": "4e499053-d199-49c6-b3cf-0865e126185f", "startPoint": { "x": 445, "y": 280 }, "endPoint": { "x": 575, "y": 140 }, "properties": {}, "pointsList": [{ "x": 445, "y": 280 }, { "x": 487, "y": 280 }, { "x": 487, "y": 140 }, { "x": 575, "y": 140 }] }, { "id": "0fddf5d5-910c-48ae-a808-24668d16130e", "type": "polyline", "sourceNodeId": "6e96f83b-9511-46cc-aa72-f3a2c095c5c0", "targetNodeId": "72094602-168b-4a01-a954-e6bdd82f4e65", "startPoint": { "x": 445, "y": 280 }, "endPoint": { "x": 635, "y": 240 }, "properties": {}, "pointsList": [{ "x": 445, "y": 280 }, { "x": 540, "y": 280 }, { "x": 540, "y": 240 }, { "x": 635, "y": 240 }] }, { "id": "284c9afc-2333-44dc-ac98-c919a94517ca", "type": "polyline", "sourceNodeId": "6e96f83b-9511-46cc-aa72-f3a2c095c5c0", "targetNodeId": "68eb5508-db0e-4361-95f9-03ff5011ebad", "startPoint": { "x": 445, "y": 280 }, "endPoint": { "x": 635, "y": 360 }, "properties": {}, "pointsList": [{ "x": 445, "y": 280 }, { "x": 540, "y": 280 }, { "x": 540, "y": 360 }, { "x": 635, "y": 360 }] }, { "id": "19c6c817-5f62-4236-a363-231b57004083", "type": "polyline", "sourceNodeId": "6e96f83b-9511-46cc-aa72-f3a2c095c5c0", "targetNodeId": "1750305e-95ad-481d-ba3c-7eccb639bcb3", "startPoint": { "x": 445, "y": 280 }, "endPoint": { "x": 575, "y": 460 }, "properties": {}, "pointsList": [{ "x": 445, "y": 280 }, { "x": 486, "y": 280 }, { "x": 486, "y": 460 }, { "x": 575, "y": 460 }] }, { "id": "b1bae994-2ba3-4d51-a502-2cfd8010cd63", "type": "polyline", "sourceNodeId": "dbc1cb70-de70-440d-9cf2-eda21dd4361d", "targetNodeId": "1ab79a26-d972-4af7-aca9-f9e705d382dc", "startPoint": { "x": 965, "y": 300 }, "endPoint": { "x": 1075, "y": 300 }, "properties": {}, "pointsList": [{ "x": 965, "y": 300 }, { "x": 1075, "y": 300 }] }] } const data = LogicDataToTestData(raw, `THEN( n76, n86, WHEN( n78, n81, THEN(WHEN(n79,n80),n84) ), n85 )`) test("when chain", () => { expect(parse(data.input)).toBe(data.output); })