import {ChildNodesChunk} from "../chunks/types/ChildNodesChunk"; import {ChunkType} from "../chunks/types/ChunkType"; import {childNodesChunkToChildNodesProps} from "./childNodesChunkToChildNodesProps"; describe("childNodesChunkToChildNodesProps()", () => { it("should convert child nodes chunk to child nodes properties", () => { const childNodesChunk: ChildNodesChunk = { "offset": { "line": 11, "column": 4 }, "type": ChunkType.ChildNodes, "children": [ { "offset": { "line": 12, "column": 6 }, "type": ChunkType.ChildNodesItem, "captures": [ "(start program):(Start)", { "type": ChunkType.NodeDecl, "captures": [ "(start program):(Start)", { "type": ChunkType.Identifier, "captures": [ "(start program)" ], "offset": { "line": 12, "column": 6 } }, { "type": ChunkType.Identifier, "captures": [ "(Start)" ], "offset": { "line": 12, "column": 6 } } ], "offset": { "line": 12, "column": 6 } } ] }, { "offset": { "line": 13, "column": 6 }, "type": ChunkType.ChildNodesItem, "children": [ { "offset": { "line": 14, "column": 8 }, "type": ChunkType.NodeParam, "captures": [ "param (value) = \"Hello, World!\"", { "type": ChunkType.VarAssignment, "captures": [ "(value) = \"Hello, World!\"", { "type": ChunkType.Identifier, "captures": [ "(value)" ], "offset": { "line": 14, "column": 8 } }, { "type": ChunkType.Any, "captures": [ "\"Hello, World!\"" ], "offset": { "line": 14, "column": 8 } } ], "offset": { "line": 14, "column": 8 } } ] } ], "content": "param (value) = \"Hello, World!\"", "captures": [ "(send \"Hello, World!\"):(Value)", { "type": ChunkType.NodeDecl, "captures": [ "(send \"Hello, World!\"):(Value)", { "type": ChunkType.Identifier, "captures": [ "(send \"Hello, World!\")" ], "offset": { "line": 13, "column": 6 } }, { "type": ChunkType.Identifier, "captures": [ "(Value)" ], "offset": { "line": 13, "column": 6 } } ], "offset": { "line": 13, "column": 6 } } ] }, { "offset": { "line": 15, "column": 6 }, "type": ChunkType.ChildNodesItem, "captures": [ "(log to console):(Console Log)", { "type": ChunkType.NodeDecl, "captures": [ "(log to console):(Console Log)", { "type": ChunkType.Identifier, "captures": [ "(log to console)" ], "offset": { "line": 15, "column": 6 } }, { "type": ChunkType.Identifier, "captures": [ "(Console Log)" ], "offset": { "line": 15, "column": 6 } } ], "offset": { "line": 15, "column": 6 } } ] } ], "content": "(start program):(Start)\n(send \"Hello, World!\"):(Value)\n param (value) = \"Hello, World!\"\n(log to console):(Console Log)", "captures": [ "children" ] }; const result = childNodesChunkToChildNodesProps(childNodesChunk); expect(result).toMatchSnapshot(); }); });