require "../spec_helper" include Nodes describe ParagraphConverter do it "converts a simple structure with no markups" do paragraphs = Array(PostResponse::Paragraph).from_json <<-JSON [ { "text": "Title", "type": "H3", "markups": [], "iframe": null, "layout": null, "metadata": null } ] JSON expected = [Heading3.new(children: [Text.new(content: "Title")] of Child)] result = ParagraphConverter.new.convert(paragraphs) result.should eq expected end it "converts a simple structure with a markup" do paragraphs = Array(PostResponse::Paragraph).from_json <<-JSON [ { "text": "inline code", "type": "P", "markups": [ { "name": null, "title": null, "type": "CODE", "href": null, "start": 7, "end": 11, "rel": null, "anchorType": null } ], "iframe": null, "layout": null, "metadata": null } ] JSON expected = [ Paragraph.new(children: [ Text.new(content: "inline "), Code.new(children: [Text.new(content: "code")] of Child), ] of Child), ] result = ParagraphConverter.new.convert(paragraphs) result.should eq expected end it "groups