require 'ecrire/markdown' require 'minitest/autorun' class MarkdownTest < Minitest::Test def test_paragraph document = Ecrire::Markdown.parse("Hello world!\nThis is nice.") assert_equal '

Hello world!

This is nice.

', document.to_html end def test_header document = Ecrire::Markdown.parse('# test') assert_equal "

test

", document.to_html document = Ecrire::Markdown.parse('## test and *some*') assert_equal "

test and some

", document.to_html end def test_italic document = Ecrire::Markdown.parse('*test*') assert_equal "

test

", document.to_html end def test_bold document = Ecrire::Markdown.parse('**test**') assert_equal "

test

", document.to_html end def test_bold_and_italic document = Ecrire::Markdown.parse('***bold and italic***') assert_equal "

bold and italic

", document.to_html document = Ecrire::Markdown.parse('**bold** and *italic*') assert_equal "

bold and italic

", document.to_html end def test_code_inline document = Ecrire::Markdown.parse("This is a ~~~ruby inline code~~~ snippet") assert_equal "

This is a inline code snippet

", document.to_html document = Ecrire::Markdown.parse("This is a ~~~ruby inline code~~~ snippet. Multiple ~~~ruby instance~~~ can coexist on the same line") assert_equal "

This is a inline code snippet. Multiple instance can coexist on the same line

", document.to_html end def test_code_blocks document = Ecrire::Markdown.parse("~~~ruby\n# A comment\nRails.application\n~~~") assert_equal "
# A comment\nRails.application
", document.to_html document = Ecrire::Markdown.parse("~~~ruby a title\n# A comment\nRails.application\n~~~") assert_equal "
a title
# A comment\nRails.application
", document.to_html end def test_unordered_list document = Ecrire::Markdown.parse("- ruby\n- Go") assert_equal '', document.to_html end def test_ordered_list document = Ecrire::Markdown.parse("1. Ruby\n2. **Go**") assert_equal '
  1. Ruby
  2. Go
', document.to_html end def test_lists document = Ecrire::Markdown.parse("1. Ruby\n2. **Go**\n- Test\n- 123") assert_equal '
  1. Ruby
  2. Go
', document.to_html end def test_lists_with_links document = Ecrire::Markdown.parse("1. [Ruby](http://ruby.com)\n") assert_equal "
  1. Ruby
", document.to_html end def test_image document = Ecrire::Markdown.parse('![An Image](http://bla.com)') assert_equal "
An Image
", document.to_html end def test_link document = Ecrire::Markdown.parse('[A link](http://bla.com)') assert_equal "

A link

", document.to_html end end