Project

General

Profile

Feature #32424 » 0004-CommonMark-formatter_test.rb.patch

Tests for #35036 - shared implementation with current Markdown formatter - Martin Cizek, 2021-04-05 16:31

View differences:

test/unit/lib/redmine/wiki_formatting/common_mark/formatter_test.rb
@formatter.new(text).update_section(3, replacement)
end
STR_SETEXT_LIKE = [
# 0
<<~STR.chomp,
# Title
STR
# 1
<<~STR.chomp,
## Heading 2
Thematic breaks - not be confused with setext headings.
---
Preceding CRLF is the default for web-submitted data.
\r
---\r
\r
A space-only line does not mean much.
\s
---
End of thematic breaks.
STR
# 2
<<~STR.chomp,
## Heading 2
Nulla nunc nisi, egestas in ornare vel, posuere ac libero.
STR
]
STR_RARE_SETEXT_LIKE = [
# 0
<<~STR.chomp,
# Title
STR
# 1
<<~STR.chomp,
## Heading 2
- item
one
-
not a heading
STR
# 2
<<~STR.chomp,
## Heading 2
Nulla nunc nisi, egestas in ornare vel, posuere ac libero.
STR
]
def test_get_section_should_ignore_setext_like_text
text = STR_SETEXT_LIKE.join("\n\n")
assert_section_with_hash STR_SETEXT_LIKE[1], text, 2
assert_section_with_hash STR_SETEXT_LIKE[2], text, 3
end
def test_get_section_should_ignore_rare_setext_like_text
begin
text = STR_RARE_SETEXT_LIKE.join("\n\n")
assert_section_with_hash STR_RARE_SETEXT_LIKE[1], text, 2
assert_section_with_hash STR_RARE_SETEXT_LIKE[2], text, 3
rescue Minitest::Assertion => e
skip "Section extraction is currently limited, see #35037. Known error: #{e.message}"
end
refute "This test should be adjusted when fixing the known error."
end
def test_should_emphasize_text
text = 'This _text_ should be emphasized'
assert_equal '<p>This <em>text</em> should be emphasized</p>', format(text)
(4-4/26)