import {ConnectionsChunk} from "../chunks/types/ConnectionsChunk"; import {ChunkType} from "../chunks/types/ChunkType"; import {connectionsChunkToConnectionArray} from "./connectionsChunkToConnectionArray"; describe("connectionsChunkToConnectionArray()", () => { it("should convert connection group chunk to list of connections", () => { const connectionsChunk: ConnectionsChunk = { "offset": { "line": 16, "column": 4 }, "type": ChunkType.Connections, "children": [ { "offset": { "line": 17, "column": 6 }, "type": ChunkType.ConnectionsItem, "captures": [ "(start program).out.(start) and (send \"Hello, World!\").in.(start)", { "type": ChunkType.ConnectionBody, "captures": [ "(start program).out.(start) and (send \"Hello, World!\").in.(start)", { "type": ChunkType.ChildPort, "captures": [ "(start program).out.(start)", { "type": ChunkType.Identifier, "captures": [ "(start program)" ], "offset": { "line": 17, "column": 6 } }, { "type": ChunkType.ChildPortDirection, "captures": [ "out" ], "offset": { "line": 17, "column": 6 } }, { "type": ChunkType.Identifier, "captures": [ "(start)" ], "offset": { "line": 17, "column": 6 } } ], "offset": { "line": 17, "column": 6 } }, { "type": ChunkType.ChildPort, "captures": [ "(send \"Hello, World!\").in.(start)", { "type": ChunkType.Identifier, "captures": [ "(send \"Hello, World!\")" ], "offset": { "line": 17, "column": 6 } }, { "type": ChunkType.ChildPortDirection, "captures": [ "in" ], "offset": { "line": 17, "column": 6 } }, { "type": ChunkType.Identifier, "captures": [ "(start)" ], "offset": { "line": 17, "column": 6 } } ], "offset": { "line": 17, "column": 6 } } ], "offset": { "line": 17, "column": 6 } } ] }, { "offset": { "line": 18, "column": 6 }, "type": ChunkType.ConnectionsItem, "captures": [ "(send \"Hello, World!\").out.(value) and (log to console).in.(value)", { "type": ChunkType.ConnectionBody, "captures": [ "(send \"Hello, World!\").out.(value) and (log to console).in.(value)", { "type": ChunkType.ChildPort, "captures": [ "(send \"Hello, World!\").out.(value)", { "type": ChunkType.Identifier, "captures": [ "(send \"Hello, World!\")" ], "offset": { "line": 18, "column": 6 } }, { "type": ChunkType.ChildPortDirection, "captures": [ "out" ], "offset": { "line": 18, "column": 6 } }, { "type": ChunkType.Identifier, "captures": [ "(value)" ], "offset": { "line": 18, "column": 6 } } ], "offset": { "line": 18, "column": 6 } }, { "type": ChunkType.ChildPort, "captures": [ "(log to console).in.(value)", { "type": ChunkType.Identifier, "captures": [ "(log to console)" ], "offset": { "line": 18, "column": 6 } }, { "type": ChunkType.ChildPortDirection, "captures": [ "in" ], "offset": { "line": 18, "column": 6 } }, { "type": ChunkType.Identifier, "captures": [ "(value)" ], "offset": { "line": 18, "column": 6 } } ], "offset": { "line": 18, "column": 6 } } ], "offset": { "line": 18, "column": 6 } } ] } ], "content": "(start program).out.(start) and (send \"Hello, World!\").in.(start)\n(send \"Hello, World!\").out.(value) and (log to console).in.(value)", "captures": [ "connect" ] }; const result = connectionsChunkToConnectionArray(connectionsChunk); expect(result).toMatchSnapshot(); }); });