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": "3cf833c8-30d6-40f0-8908-7af47b422f74", "type": "ID", "x": -160, "y": 700, "properties": { "name": "n77", "nodeId": "n77" } }, { "id": "4f3221dd-7a6c-4454-8dac-b591ed2e240a", "type": "ID", "x": 120, "y": 500, "properties": { "name": "n78", "nodeId": "n78" } }, { "id": "4ea71047-44cf-4ca2-97cf-826f84048a58", "type": "ID", "x": 120, "y": 700, "properties": { "name": "n79", "nodeId": "n79" } }, { "id": "2f5e68d1-669e-406d-aa99-2fa39b0df4f0", "type": "ID", "x": 120, "y": 840, "properties": { "name": "n80", "nodeId": "n80" } }, { "id": "2fa77b22-d54a-4b78-9758-5490aa5170a2", "type": "ID", "x": 580, "y": 500, "properties": { "name": "n81", "nodeId": "n81" } }, { "id": "cea770b1-3f9a-4408-9f75-e14a4101942b", "type": "ID", "x": 1500, "y": 680, "properties": { "name": "n82", "nodeId": "n82" } }, { "id": "13f026b3-86a7-4d8d-ad90-13833f473e45", "type": "ID", "x": 460, "y": 700, "properties": { "name": "n83", "nodeId": "n83" } }, { "id": "de455def-0ec8-45b2-838d-0a70aa2966b8", "type": "ID", "x": 620, "y": 700, "properties": { "name": "n84", "nodeId": "n84" } }, { "id": "74a9780e-123c-49eb-84a4-007c53a8e83d", "type": "ID", "x": 480, "y": 820, "properties": { "name": "n85", "nodeId": "n85" } }, { "id": "7b6c6725-d562-493b-8655-ccaec10866dd", "type": "ID", "x": 480, "y": 980, "properties": { "name": "n86", "nodeId": "n86" } }, { "id": "c48ea6e4-d494-4f6b-baa2-a2fd55c9cad1", "type": "ID", "x": 660, "y": 820, "properties": { "name": "n87", "nodeId": "n87" } }, { "id": "4c5bc5d8-3a17-4398-8ea0-d1417454376d", "type": "ID", "x": 660, "y": 980, "properties": { "name": "n88", "nodeId": "n88" } }, { "id": "e8508aea-7782-44c3-b64d-56a4eaef2299", "type": "ID", "x": 880, "y": 780, "properties": { "name": "n89", "nodeId": "n89" } }, { "id": "5d7c40f6-28a6-4145-b971-f377fd457a5f", "type": "ID", "x": 880, "y": 880, "properties": { "name": "n90", "nodeId": "n90" } }, { "id": "25110a11-bd50-4db6-8880-70f4e16ca81d", "type": "ID", "x": 1120, "y": 880, "properties": { "name": "n91", "nodeId": "n91" } }], "edges": [{ "id": "657598f8-60b4-4b05-b31a-749592e27a70", "type": "bezier", "sourceNodeId": "3cf833c8-30d6-40f0-8908-7af47b422f74", "targetNodeId": "4f3221dd-7a6c-4454-8dac-b591ed2e240a", "startPoint": { "x": -115, "y": 700 }, "endPoint": { "x": 75, "y": 500 }, "properties": {}, "pointsList": [{ "x": -115, "y": 700 }, { "x": -15, "y": 700 }, { "x": -25, "y": 500 }, { "x": 75, "y": 500 }] }, { "id": "a8e17365-418c-46c7-8357-8496d6aa918d", "type": "bezier", "sourceNodeId": "4f3221dd-7a6c-4454-8dac-b591ed2e240a", "targetNodeId": "2fa77b22-d54a-4b78-9758-5490aa5170a2", "startPoint": { "x": 165, "y": 500 }, "endPoint": { "x": 535, "y": 500 }, "properties": {}, "pointsList": [{ "x": 165, "y": 500 }, { "x": 265, "y": 500 }, { "x": 435, "y": 500 }, { "x": 535, "y": 500 }] }, { "id": "4a67f7c0-b9a8-4208-9e38-1080430d181d", "type": "bezier", "sourceNodeId": "2fa77b22-d54a-4b78-9758-5490aa5170a2", "targetNodeId": "cea770b1-3f9a-4408-9f75-e14a4101942b", "startPoint": { "x": 625, "y": 500 }, "endPoint": { "x": 1455, "y": 680 }, "properties": {}, "pointsList": [{ "x": 625, "y": 500 }, { "x": 725, "y": 500 }, { "x": 1355, "y": 680 }, { "x": 1455, "y": 680 }] }, { "id": "d08d9a0c-5b95-4987-927b-cda3966e83a3", "type": "bezier", "sourceNodeId": "3cf833c8-30d6-40f0-8908-7af47b422f74", "targetNodeId": "4ea71047-44cf-4ca2-97cf-826f84048a58", "startPoint": { "x": -115, "y": 700 }, "endPoint": { "x": 75, "y": 700 }, "properties": {}, "pointsList": [{ "x": -115, "y": 700 }, { "x": -15, "y": 700 }, { "x": -25, "y": 700 }, { "x": 75, "y": 700 }] }, { "id": "7bccda52-069a-47ae-aff9-e242c5b28ca7", "type": "bezier", "sourceNodeId": "4ea71047-44cf-4ca2-97cf-826f84048a58", "targetNodeId": "13f026b3-86a7-4d8d-ad90-13833f473e45", "startPoint": { "x": 165, "y": 700 }, "endPoint": { "x": 415, "y": 700 }, "properties": {}, "pointsList": [{ "x": 165, "y": 700 }, { "x": 265, "y": 700 }, { "x": 315, "y": 700 }, { "x": 415, "y": 700 }] }, { "id": "b2f8b3df-7130-4b47-92e7-018d9821cbca", "type": "bezier", "sourceNodeId": "13f026b3-86a7-4d8d-ad90-13833f473e45", "targetNodeId": "de455def-0ec8-45b2-838d-0a70aa2966b8", "startPoint": { "x": 505, "y": 700 }, "endPoint": { "x": 575, "y": 700 }, "properties": {}, "pointsList": [{ "x": 505, "y": 700 }, { "x": 605, "y": 700 }, { "x": 475, "y": 700 }, { "x": 575, "y": 700 }] }, { "id": "3694edad-a079-4513-9d3a-42359658c897", "type": "bezier", "sourceNodeId": "de455def-0ec8-45b2-838d-0a70aa2966b8", "targetNodeId": "cea770b1-3f9a-4408-9f75-e14a4101942b", "startPoint": { "x": 665, "y": 700 }, "endPoint": { "x": 1455, "y": 680 }, "properties": {}, "pointsList": [{ "x": 665, "y": 700 }, { "x": 765, "y": 700 }, { "x": 1355, "y": 680 }, { "x": 1455, "y": 680 }] }, { "id": "340722f8-f462-480d-9754-0f4948c68893", "type": "bezier", "sourceNodeId": "3cf833c8-30d6-40f0-8908-7af47b422f74", "targetNodeId": "2f5e68d1-669e-406d-aa99-2fa39b0df4f0", "startPoint": { "x": -115, "y": 700 }, "endPoint": { "x": 75, "y": 840 }, "properties": {}, "pointsList": [{ "x": -115, "y": 700 }, { "x": -15, "y": 700 }, { "x": -25, "y": 840 }, { "x": 75, "y": 840 }] }, { "id": "6184946c-c478-4aa7-8fb3-f99c4c371e4a", "type": "bezier", "sourceNodeId": "2f5e68d1-669e-406d-aa99-2fa39b0df4f0", "targetNodeId": "74a9780e-123c-49eb-84a4-007c53a8e83d", "startPoint": { "x": 165, "y": 840 }, "endPoint": { "x": 435, "y": 820 }, "properties": {}, "pointsList": [{ "x": 165, "y": 840 }, { "x": 265, "y": 840 }, { "x": 335, "y": 820 }, { "x": 435, "y": 820 }] }, { "id": "23b3546d-ee1c-4c66-a93c-c0ed662dc618", "type": "bezier", "sourceNodeId": "2f5e68d1-669e-406d-aa99-2fa39b0df4f0", "targetNodeId": "7b6c6725-d562-493b-8655-ccaec10866dd", "startPoint": { "x": 165, "y": 840 }, "endPoint": { "x": 435, "y": 980 }, "properties": {}, "pointsList": [{ "x": 165, "y": 840 }, { "x": 265, "y": 840 }, { "x": 335, "y": 980 }, { "x": 435, "y": 980 }] }, { "id": "80e98205-9839-4e79-82a2-9cfb0c24833c", "type": "bezier", "sourceNodeId": "74a9780e-123c-49eb-84a4-007c53a8e83d", "targetNodeId": "c48ea6e4-d494-4f6b-baa2-a2fd55c9cad1", "startPoint": { "x": 525, "y": 820 }, "endPoint": { "x": 615, "y": 820 }, "properties": {}, "pointsList": [{ "x": 525, "y": 820 }, { "x": 625, "y": 820 }, { "x": 515, "y": 820 }, { "x": 615, "y": 820 }] }, { "id": "e986bacf-1d31-4608-bba4-ad2a04067dda", "type": "bezier", "sourceNodeId": "7b6c6725-d562-493b-8655-ccaec10866dd", "targetNodeId": "4c5bc5d8-3a17-4398-8ea0-d1417454376d", "startPoint": { "x": 525, "y": 980 }, "endPoint": { "x": 615, "y": 980 }, "properties": {}, "pointsList": [{ "x": 525, "y": 980 }, { "x": 625, "y": 980 }, { "x": 515, "y": 980 }, { "x": 615, "y": 980 }] }, { "id": "054c6f05-cc21-4ac0-86cf-76f4c3450928", "type": "bezier", "sourceNodeId": "c48ea6e4-d494-4f6b-baa2-a2fd55c9cad1", "targetNodeId": "e8508aea-7782-44c3-b64d-56a4eaef2299", "startPoint": { "x": 705, "y": 820 }, "endPoint": { "x": 835, "y": 780 }, "properties": {}, "pointsList": [{ "x": 705, "y": 820 }, { "x": 805, "y": 820 }, { "x": 735, "y": 780 }, { "x": 835, "y": 780 }] }, { "id": "6d381e11-4e1c-47e6-b56d-041efc8583a4", "type": "bezier", "sourceNodeId": "c48ea6e4-d494-4f6b-baa2-a2fd55c9cad1", "targetNodeId": "5d7c40f6-28a6-4145-b971-f377fd457a5f", "startPoint": { "x": 705, "y": 820 }, "endPoint": { "x": 835, "y": 880 }, "properties": {}, "pointsList": [{ "x": 705, "y": 820 }, { "x": 805, "y": 820 }, { "x": 735, "y": 880 }, { "x": 835, "y": 880 }] }, { "id": "5c39576e-2070-4cd2-8b49-f53a9ef374d6", "type": "bezier", "sourceNodeId": "e8508aea-7782-44c3-b64d-56a4eaef2299", "targetNodeId": "25110a11-bd50-4db6-8880-70f4e16ca81d", "startPoint": { "x": 925, "y": 780 }, "endPoint": { "x": 1075, "y": 880 }, "properties": {}, "pointsList": [{ "x": 925, "y": 780 }, { "x": 1025, "y": 780 }, { "x": 975, "y": 880 }, { "x": 1075, "y": 880 }] }, { "id": "884f98ef-ea84-4d8e-9ca4-8b17f5c604dc", "type": "bezier", "sourceNodeId": "25110a11-bd50-4db6-8880-70f4e16ca81d", "targetNodeId": "cea770b1-3f9a-4408-9f75-e14a4101942b", "startPoint": { "x": 1165, "y": 880 }, "endPoint": { "x": 1455, "y": 680 }, "properties": {}, "pointsList": [{ "x": 1165, "y": 880 }, { "x": 1265, "y": 880 }, { "x": 1355, "y": 680 }, { "x": 1455, "y": 680 }] }, { "id": "27762537-1a2c-4388-955f-d5ebc7154c22", "type": "bezier", "sourceNodeId": "5d7c40f6-28a6-4145-b971-f377fd457a5f", "targetNodeId": "25110a11-bd50-4db6-8880-70f4e16ca81d", "startPoint": { "x": 925, "y": 880 }, "endPoint": { "x": 1075, "y": 880 }, "properties": {}, "pointsList": [{ "x": 925, "y": 880 }, { "x": 1025, "y": 880 }, { "x": 975, "y": 880 }, { "x": 1075, "y": 880 }] }, { "id": "6aeb66e8-b07a-4d92-a76a-e0b3f5dfd39c", "type": "bezier", "sourceNodeId": "4c5bc5d8-3a17-4398-8ea0-d1417454376d", "targetNodeId": "25110a11-bd50-4db6-8880-70f4e16ca81d", "startPoint": { "x": 705, "y": 980 }, "endPoint": { "x": 1075, "y": 880 }, "properties": {}, "pointsList": [{ "x": 705, "y": 980 }, { "x": 805, "y": 980 }, { "x": 975, "y": 880 }, { "x": 1075, "y": 880 }] }] } const data = LogicDataToTestData(raw, `THEN( n77, WHEN( THEN(n78,n81), THEN( n80, WHEN( THEN( n85, n87, WHEN(n89,n90) ), THEN(n86,n88) ), n91 ), THEN(n79,n83,n84) ), n82 )`) test("when chain3", () => { expect(parse(data.input)).toBe(data.output); })