Sha256: 7cff17d579c0ca753e4af7ada78c9656cd3cfff382c331e15e05d9bd0ebf9572

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

mock_node = {"content" => [
  {
    "content" => [{
      "content" => [{
        "value" => "foo",
        "nodeType" => "text",
        "nodeClass" => "text"
      }],
      "nodeType" => "paragraph",
      "nodeClass" => "block"
    }],
    "nodeType" => "list-item",
    "nodeClass" => "block"
  }]
}

mock_node_with_marks = {"content" => [
  {
    "content" => [{
      "content" => [{
        "marks" => [{"type" => "bold"}],
        "value" => "foo",
        "nodeType" => "text",
        "nodeClass" => "text"
      }],
      "nodeType" => "paragraph",
      "nodeClass" => "block"
    }],
    "nodeType" => "list-item",
    "nodeClass" => "block"
  }]
}


describe StructuredTextRenderer::UnorderedListRenderer do
  subject do
    described_class.new(
      'paragraph' => StructuredTextRenderer::ParagraphRenderer,
      'text' => StructuredTextRenderer::TextRenderer,
      'bold' => StructuredTextRenderer::BoldRenderer,
      'list-item' => StructuredTextRenderer::ListItemRenderer
    )
  end

  describe '#render' do
    it 'renders a ul' do
      expect(subject.render(mock_node)).to eq "<ul><li><p>foo</p></li></ul>"
    end

    it 'will propagate marks to text renderers' do
      expect(subject.render(mock_node_with_marks)).to eq "<ul><li><p><b>foo</b></p></li></ul>"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
structured_text_renderer-0.0.2 spec/lib/structured_text_renderer/block_renderers/unordered_list_renderer_spec.rb
structured_text_renderer-0.0.1 spec/lib/structured_text_renderer/block_renderers/unordered_list_renderer_spec.rb