Sha256: 1139ce331b9db03c6158c380ae9605d9aafb8c891f003a7ce8ee0c6ba8be57f8

Contents?: true

Size: 864 Bytes

Versions: 1

Compression:

Stored size: 864 Bytes

Contents

require 'test_helper'

class TestNode < Minitest::Test
  def setup
    @doc = Node.parse_string("Hi *there*")
  end

  def test_walk
    nodes = []
    @doc.walk do |node|
      nodes << node.type
    end
    assert_equal [:document, :paragraph, :text, :emph, :text], nodes
  end

  def test_insert_illegal
    assert_raises NodeError do
      @doc.insert_before(@doc)
    end
  end

  def test_to_html
    assert_equal "<p>Hi <em>there</em></p>\n", @doc.to_html
  end

  def test_html_renderer
    renderer = HtmlRenderer.new
    result = renderer.render(@doc)
    assert_equal "<p>Hi <em>there</em></p>\n", result
  end

  def test_walk_and_set_string_content
    @doc.walk do |node|
      if node.type == :text && node.string_content == 'there'
        node.string_content = 'world'
        assert_equal 'world', node.string_content
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
commonmarker-0.1.3 test/test_basics.rb