@@ -1,16 +1,16 | |||
|
1 | 1 | # Redmine - project management software |
|
2 |
# Copyright (C) 2006-201 |
|
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 |
# |
|
|
8 | # | |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 |
# |
|
|
13 | # | |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
@@ -22,7 +22,7 class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase | |||
|
22 | 22 | def setup |
|
23 | 23 | @formatter = Redmine::WikiFormatting::Textile::Formatter |
|
24 | 24 | end |
|
25 | ||
|
25 | ||
|
26 | 26 | MODIFIERS = { |
|
27 | 27 | "*" => 'strong', # bold |
|
28 | 28 | "_" => 'em', # italic |
@@ -31,7 +31,7 class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase | |||
|
31 | 31 | "^" => 'sup', # superscript |
|
32 | 32 | "~" => 'sub' # subscript |
|
33 | 33 | } |
|
34 | ||
|
34 | ||
|
35 | 35 | def test_modifiers |
|
36 | 36 | assert_html_output( |
|
37 | 37 | '*bold*' => '<strong>bold</strong>', |
@@ -46,7 +46,7 class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase | |||
|
46 | 46 | '*(foo)two words*' => '<strong class="foo">two words</strong>' |
|
47 | 47 | ) |
|
48 | 48 | end |
|
49 | ||
|
49 | ||
|
50 | 50 | def test_modifiers_combination |
|
51 | 51 | MODIFIERS.each do |m1, tag1| |
|
52 | 52 | MODIFIERS.each do |m2, tag2| |
@@ -57,7 +57,7 class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase | |||
|
57 | 57 | end |
|
58 | 58 | end |
|
59 | 59 | end |
|
60 | ||
|
60 | ||
|
61 | 61 | def test_inline_code |
|
62 | 62 | assert_html_output( |
|
63 | 63 | 'this is @some code@' => 'this is <code>some code</code>', |
@@ -76,14 +76,14 class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase | |||
|
76 | 76 | 'h1. 2009\02\09' => '<h1>2009\02\09</h1>' |
|
77 | 77 | }, false) |
|
78 | 78 | end |
|
79 | ||
|
79 | ||
|
80 | 80 | def test_double_dashes_should_not_strikethrough |
|
81 | 81 | assert_html_output( |
|
82 | 82 | 'double -- dashes -- test' => 'double -- dashes -- test', |
|
83 | 83 | 'double -- *dashes* -- test' => 'double -- <strong>dashes</strong> -- test' |
|
84 | 84 | ) |
|
85 | 85 | end |
|
86 | ||
|
86 | ||
|
87 | 87 | def test_acronyms |
|
88 | 88 | assert_html_output( |
|
89 | 89 | 'this is an acronym: GPL(General Public License)' => 'this is an acronym: <acronym title="General Public License">GPL</acronym>', |
@@ -91,7 +91,7 class Redmine::WikiFormatting::TextileFormatterTest < HelperTestCase | |||
|
91 | 91 | 'GPL(This is a double-quoted "title")' => '<acronym title="This is a double-quoted "title"">GPL</acronym>' |
|
92 | 92 | ) |
|
93 | 93 | end |
|
94 | ||
|
94 | ||
|
95 | 95 | def test_blockquote |
|
96 | 96 | # orig raw text |
|
97 | 97 | raw = <<-RAW |
@@ -108,7 +108,7 John said: | |||
|
108 | 108 | |
|
109 | 109 | He's right. |
|
110 | 110 | RAW |
|
111 | ||
|
111 | ||
|
112 | 112 | # expected html |
|
113 | 113 | expected = <<-EXPECTED |
|
114 | 114 | <p>John said:</p> |
@@ -128,10 +128,10 Nullam commodo metus accumsan nulla. Curabitur lobortis dui id dolor. | |||
|
128 | 128 | </blockquote> |
|
129 | 129 | <p>He's right.</p> |
|
130 | 130 | EXPECTED |
|
131 | ||
|
131 | ||
|
132 | 132 | assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '') |
|
133 | 133 | end |
|
134 | ||
|
134 | ||
|
135 | 135 | def test_table |
|
136 | 136 | raw = <<-RAW |
|
137 | 137 | This is a table with empty cells: |
@@ -153,7 +153,7 EXPECTED | |||
|
153 | 153 | |
|
154 | 154 | assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '') |
|
155 | 155 | end |
|
156 | ||
|
156 | ||
|
157 | 157 | def test_table_with_line_breaks |
|
158 | 158 | raw = <<-RAW |
|
159 | 159 | This is a table with line breaks: |
@@ -192,19 +192,19 EXPECTED | |||
|
192 | 192 | |
|
193 | 193 | assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '') |
|
194 | 194 | end |
|
195 | ||
|
195 | ||
|
196 | 196 | def test_textile_should_not_mangle_brackets |
|
197 | 197 | assert_equal '<p>[msg1][msg2]</p>', to_html('[msg1][msg2]') |
|
198 | 198 | end |
|
199 | ||
|
199 | ||
|
200 | 200 | private |
|
201 | ||
|
201 | ||
|
202 | 202 | def assert_html_output(to_test, expect_paragraph = true) |
|
203 | 203 | to_test.each do |text, expected| |
|
204 | 204 | assert_equal(( expect_paragraph ? "<p>#{expected}</p>" : expected ), @formatter.new(text).to_html, "Formatting the following text failed:\n===\n#{text}\n===\n") |
|
205 | 205 | end |
|
206 | 206 | end |
|
207 | ||
|
207 | ||
|
208 | 208 | def to_html(text) |
|
209 | 209 | @formatter.new(text).to_html |
|
210 | 210 | end |
General Comments 0
You need to be logged in to leave comments.
Login now