-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcode_test.rb
More file actions
99 lines (86 loc) · 2.23 KB
/
code_test.rb
File metadata and controls
99 lines (86 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
require File.join(File.expand_path(File.dirname(__FILE__)), 'test_helper.rb')
class TestCode < Minitest::Test
include RbbCode::Heredoc
include RbbCode::OutputAssertions
def test_empty_code_to_html
assert_converts_to(
'<code></code>',
'[code][/code]'
)
end
def test_single_line_code_to_html
assert_converts_to(
'<code><p>Quoth the raven</p></code>',
'[code]Quoth the raven[/code]'
)
end
def test_multi_line_code_to_html
assert_converts_to(
'<code><p>Quoth the</p><p>raven</p></code>',
heredoc(%(
[code]Quoth
the
raven[/code]
))
)
end
def test_empty_code_to_markdown
assert_converts_to(
" \n\n",
'[code][/code]',
output_format: :markdown
)
end
def test_single_line_code_to_markdown
assert_converts_to(
" Quoth the raven\n\n",
'[code]Quoth the raven[/code]',
output_format: :markdown
)
end
def test_multi_line_code_to_markdown
assert_converts_to(
" Quoth\n the\n \n raven\n\n",
heredoc(%(
[code]Quoth
the
raven[/code]
)),
output_format: :markdown
)
end
# Test that we can handle arbitrary line breaks before or after the inner BBCode.
def test_pre_and_post_breaks
0.upto(3) do |pre_breaks|
0.upto(3).each do |post_breaks|
bb_code = '[code]' + ("\n" * pre_breaks) + 'Quoth the raven' + ("\n" * post_breaks) + '[/code]'
assert_converts_to(
'<code><p>Quoth the raven</p></code>',
bb_code,
{},
"HTML output not correct for #{pre_breaks} pre-break(s) and #{post_breaks} post-break(s)."
)
end
end
0.upto(3) do |pre_breaks|
0.upto(3).each do |post_breaks|
inner = heredoc(%(
Quoth
the
raven
))
bb_code = '[code]' + ("\n" * pre_breaks) + inner + ("\n" * post_breaks) + '[/code]'
assert_converts_to(
'<code>
<p>Quoth</p>
<p>the</p>
<p>raven</p>
</code>',
bb_code,
{},
"HTML output not correct for #{pre_breaks} pre-break(s) and #{post_breaks} post-break(s)."
)
end
end
end
end