import { test, expect } from 'vitest'; import parse, { reSpace } from '../parse'; const data: any = { "input": { "nodes": [{ "id": "b3d2fb20-6d96-4c13-aaef-0b8a84fe7a5d", "type": "GROUP", "x": 460, "y": 820, "properties": { "height": null, "width": null, "groupType": "LOGIC", "isFolded": false, "groupAddable": false, "id": "b3d2fb20-6d96-4c13-aaef-0b8a84fe7a5d", "must": [], "nodeSize": { "width": 473, "height": 284 } }, "children": ["daa89812-b3c7-43a6-b584-536420ccada8", "12b6e224-9a03-45dc-b3ea-fff05b068c40", "5af06912-57e4-4e16-8cff-4f4c515a2ecb", "75d9e845-48a6-47d0-a2fd-e608da39d159", "9ba7ca31-e01e-4bd0-a410-23497367c20f", "dea0bfa8-7dfb-448d-ac15-6c9fe81f3897"], "sourceNodeIds": [], "targetNodeIds": [], "flowData": { "nodes": [{ "id": "daa89812-b3c7-43a6-b584-536420ccada8", "type": "AND", "x": 420, "y": 760, "properties": { "name": "AND", "nodeId": "n21" } }, { "id": "12b6e224-9a03-45dc-b3ea-fff05b068c40", "type": "ID", "x": 280, "y": 740, "properties": { "name": "n20", "nodeId": "n20" } }, { "id": "5af06912-57e4-4e16-8cff-4f4c515a2ecb", "type": "ID", "x": 280, "y": 820, "properties": { "name": "n22", "nodeId": "n22" } }, { "id": "75d9e845-48a6-47d0-a2fd-e608da39d159", "type": "ID", "x": 300, "y": 920, "properties": { "name": "n24", "nodeId": "n24" } }, { "id": "9ba7ca31-e01e-4bd0-a410-23497367c20f", "type": "NOT", "x": 640, "y": 840, "properties": { "name": "NOT", "nodeId": "n25" } }, { "id": "dea0bfa8-7dfb-448d-ac15-6c9fe81f3897", "type": "OR", "x": 540, "y": 840, "properties": { "name": "OR", "nodeId": "n23" } }], "edges": [{ "id": "d6b1f653-cb1c-4152-bb68-f5a081854c37", "type": "custom", "sourceNodeId": "12b6e224-9a03-45dc-b3ea-fff05b068c40", "targetNodeId": "daa89812-b3c7-43a6-b584-536420ccada8", "startPoint": { "x": 324, "y": 740.5 }, "endPoint": { "x": 383, "y": 751.5 }, "properties": {}, "pointsList": [{ "x": 324, "y": 740.5 }, { "x": 424, "y": 740.5 }, { "x": 283, "y": 751.5 }, { "x": 383, "y": 751.5 }] }, { "id": "ee0d3e15-5762-4f30-aeac-a4847214584a", "type": "custom", "sourceNodeId": "5af06912-57e4-4e16-8cff-4f4c515a2ecb", "targetNodeId": "daa89812-b3c7-43a6-b584-536420ccada8", "startPoint": { "x": 324, "y": 820.5 }, "endPoint": { "x": 383, "y": 769.5 }, "properties": {}, "pointsList": [{ "x": 324, "y": 820.5 }, { "x": 424, "y": 820.5 }, { "x": 283, "y": 769.5 }, { "x": 383, "y": 769.5 }] }, { "id": "acdd88c3-ff5e-40bb-a763-9431666f41fd", "type": "custom", "sourceNodeId": "dea0bfa8-7dfb-448d-ac15-6c9fe81f3897", "targetNodeId": "9ba7ca31-e01e-4bd0-a410-23497367c20f", "startPoint": { "x": 576, "y": 840 }, "endPoint": { "x": 604, "y": 840 }, "properties": {}, "pointsList": [{ "x": 576, "y": 840 }, { "x": 676, "y": 840 }, { "x": 504, "y": 840 }, { "x": 604, "y": 840 }] }, { "id": "c846b118-78bf-4863-af3a-45e52df63d15", "type": "custom", "sourceNodeId": "75d9e845-48a6-47d0-a2fd-e608da39d159", "targetNodeId": "dea0bfa8-7dfb-448d-ac15-6c9fe81f3897", "startPoint": { "x": 345, "y": 920 }, "endPoint": { "x": 504, "y": 849 }, "properties": {}, "pointsList": [{ "x": 345, "y": 920 }, { "x": 445, "y": 920 }, { "x": 404, "y": 849 }, { "x": 504, "y": 849 }] }, { "id": "23ddc7e0-21da-4b3f-8cbd-dfaad33e1bf5", "type": "custom", "sourceNodeId": "daa89812-b3c7-43a6-b584-536420ccada8", "targetNodeId": "dea0bfa8-7dfb-448d-ac15-6c9fe81f3897", "startPoint": { "x": 455, "y": 760.5 }, "endPoint": { "x": 504, "y": 831 }, "properties": {}, "pointsList": [{ "x": 455, "y": 760.5 }, { "x": 555, "y": 760.5 }, { "x": 404, "y": 831 }, { "x": 504, "y": 831 }] }] } }, { "id": "12b6e224-9a03-45dc-b3ea-fff05b068c40", "type": "ID", "x": 280, "y": 740, "properties": { "name": "n20", "nodeId": "n20" } }, { "id": "daa89812-b3c7-43a6-b584-536420ccada8", "type": "AND", "x": 420, "y": 760, "properties": { "name": "AND", "nodeId": "n21" } }, { "id": "5af06912-57e4-4e16-8cff-4f4c515a2ecb", "type": "ID", "x": 280, "y": 820, "properties": { "name": "n22", "nodeId": "n22" } }, { "id": "dea0bfa8-7dfb-448d-ac15-6c9fe81f3897", "type": "OR", "x": 540, "y": 840, "properties": { "name": "OR", "nodeId": "n23" } }, { "id": "75d9e845-48a6-47d0-a2fd-e608da39d159", "type": "ID", "x": 300, "y": 920, "properties": { "name": "n24", "nodeId": "n24" } }, { "id": "9ba7ca31-e01e-4bd0-a410-23497367c20f", "type": "NOT", "x": 640, "y": 840, "properties": { "name": "NOT", "nodeId": "n25" } }], "edges": [{ "id": "d6b1f653-cb1c-4152-bb68-f5a081854c37", "type": "custom", "sourceNodeId": "12b6e224-9a03-45dc-b3ea-fff05b068c40", "targetNodeId": "daa89812-b3c7-43a6-b584-536420ccada8", "startPoint": { "x": 324, "y": 740.5 }, "endPoint": { "x": 383, "y": 751.5 }, "properties": {}, "pointsList": [{ "x": 324, "y": 740.5 }, { "x": 424, "y": 740.5 }, { "x": 283, "y": 751.5 }, { "x": 383, "y": 751.5 }] }, { "id": "ee0d3e15-5762-4f30-aeac-a4847214584a", "type": "custom", "sourceNodeId": "5af06912-57e4-4e16-8cff-4f4c515a2ecb", "targetNodeId": "daa89812-b3c7-43a6-b584-536420ccada8", "startPoint": { "x": 324, "y": 820.5 }, "endPoint": { "x": 383, "y": 769.5 }, "properties": {}, "pointsList": [{ "x": 324, "y": 820.5 }, { "x": 424, "y": 820.5 }, { "x": 283, "y": 769.5 }, { "x": 383, "y": 769.5 }] }, { "id": "c846b118-78bf-4863-af3a-45e52df63d15", "type": "custom", "sourceNodeId": "75d9e845-48a6-47d0-a2fd-e608da39d159", "targetNodeId": "dea0bfa8-7dfb-448d-ac15-6c9fe81f3897", "startPoint": { "x": 345, "y": 920 }, "endPoint": { "x": 504, "y": 849 }, "properties": {}, "pointsList": [{ "x": 345, "y": 920 }, { "x": 445, "y": 920 }, { "x": 404, "y": 849 }, { "x": 504, "y": 849 }] }, { "id": "23ddc7e0-21da-4b3f-8cbd-dfaad33e1bf5", "type": "custom", "sourceNodeId": "daa89812-b3c7-43a6-b584-536420ccada8", "targetNodeId": "dea0bfa8-7dfb-448d-ac15-6c9fe81f3897", "startPoint": { "x": 455, "y": 760.5 }, "endPoint": { "x": 504, "y": 831 }, "properties": {}, "pointsList": [{ "x": 455, "y": 760.5 }, { "x": 555, "y": 760.5 }, { "x": 404, "y": 831 }, { "x": 504, "y": 831 }] }, { "id": "acdd88c3-ff5e-40bb-a763-9431666f41fd", "type": "custom", "sourceNodeId": "dea0bfa8-7dfb-448d-ac15-6c9fe81f3897", "targetNodeId": "9ba7ca31-e01e-4bd0-a410-23497367c20f", "startPoint": { "x": 576, "y": 840 }, "endPoint": { "x": 604, "y": 840 }, "properties": {}, "pointsList": [{ "x": 576, "y": 840 }, { "x": 676, "y": 840 }, { "x": 504, "y": 840 }, { "x": 604, "y": 840 }] }] }, output: `NOT(OR(n24,AND(n20,n22)))` } test("logic", () => { expect( reSpace(parse(data.input)) ).toBe(reSpace(data.output)); })