mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 16:52:45 +08:00
REFACTOR: Move Markdown tests to Javascript land
This commit is contained in:
parent
46bdd13491
commit
b2f2e7b1d2
|
@ -266,43 +266,4 @@ describe PrettyText do
|
|||
end
|
||||
end
|
||||
|
||||
describe "markdown quirks" do
|
||||
|
||||
it "sanitizes spans" do
|
||||
PrettyText.cook("<span class=\"-bbcode-size-0 fa fa-spin\">a</span>").should match_html "<p><span>a</span></p>"
|
||||
PrettyText.cook("<span class=\"fa fa-spin -bbcode-size-0\">a</span>").should match_html "<p><span>a</span></p>"
|
||||
PrettyText.cook("<span class=\"bbcode-size-10\">a</span>").should match_html "<p><span class=\"bbcode-size-10\">a</span></p>"
|
||||
end
|
||||
|
||||
it "bolds stuff in parens" do
|
||||
PrettyText.cook("a \"**hello**\"").should match_html "<p>a "<strong>hello</strong>"</p>"
|
||||
PrettyText.cook("(**hello**)").should match_html "<p>(<strong>hello</strong>)</p>"
|
||||
# is it me your looking for?
|
||||
end
|
||||
it "allows for newline after bold" do
|
||||
PrettyText.cook("**hello**\nworld").should match_html "<p><strong>hello</strong><br />world</p>"
|
||||
end
|
||||
it "allows for newline for 2 bolds" do
|
||||
PrettyText.cook("**hello**\n**world**").should match_html "<p><strong>hello</strong><br /><strong>world</strong></p>"
|
||||
end
|
||||
|
||||
it "allows for * and _ in bold" do
|
||||
PrettyText.cook("**a*_b**").should match_html "<p><strong>a*_b</strong></p>"
|
||||
end
|
||||
|
||||
it "does not apply italics when there is a space inside" do
|
||||
PrettyText.cook("** hello**").should match_html "<p>** hello**</p>"
|
||||
PrettyText.cook("**hello **").should match_html "<p>**hello **</p>"
|
||||
end
|
||||
|
||||
it "allows does not bold chinese intra word" do
|
||||
PrettyText.cook("你**hello**").should match_html "<p>你**hello**</p>"
|
||||
end
|
||||
|
||||
it "allows bold chinese" do
|
||||
PrettyText.cook("**你hello**").should match_html "<p><strong>你hello</strong></p>"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -261,9 +261,19 @@ test("Mentions", function() {
|
|||
|
||||
|
||||
test("Heading", function() {
|
||||
cooked("**Bold**\n----------",
|
||||
"<h2><strong>Bold</strong></h2>",
|
||||
"It will bold the heading");
|
||||
cooked("**Bold**\n----------", "<h2><strong>Bold</strong></h2>", "It will bold the heading");
|
||||
});
|
||||
|
||||
test("bold and italics", function() {
|
||||
cooked("a \"**hello**\"", "<p>a \"<strong>hello</strong>\"</p>", "bolds in quotes");
|
||||
cooked("(**hello**)", "<p>(<strong>hello</strong>)</p>", "bolds in parens");
|
||||
cooked("**hello**\nworld", "<p><strong>hello</strong><br>world</p>", "allows newline after bold");
|
||||
cooked("**hello**\n**world**", "<p><strong>hello</strong><br><strong>world</strong></p>", "newline between two bolds");
|
||||
cooked("**a*_b**", "<p><strong>a*_b</strong></p>", "allows for characters within bold");
|
||||
cooked("** hello**", "<p>** hello**</p>", "does not bold on a space boundary");
|
||||
cooked("**hello **", "<p>**hello **</p>", "does not bold on a space boundary");
|
||||
cooked("你**hello**", "<p>你**hello**</p>", "does not bold chinese intra word");
|
||||
cooked("**你hello**", "<p><strong>你hello</strong></p>", "allows bolded chinese");
|
||||
});
|
||||
|
||||
test("Oneboxing", function() {
|
||||
|
@ -388,6 +398,10 @@ test("sanitize", function() {
|
|||
cooked("[the answer](javascript:alert(42))", "<p><a>the answer</a></p>", "it prevents XSS");
|
||||
|
||||
cooked("<i class=\"fa fa-bug fa-spin\" style=\"font-size:600%\"></i>\n<!-- -->", "<p><i></i><br/></p>", "it doesn't circumvent XSS with comments");
|
||||
|
||||
cooked("<span class=\"-bbcode-size-0 fa fa-spin\">a</span>", "<p><span>a</span></p>", "it sanitizes spans");
|
||||
cooked("<span class=\"fa fa-spin -bbcode-size-0\">a</span>", "<p><span>a</span></p>", "it sanitizes spans");
|
||||
cooked("<span class=\"bbcode-size-10\">a</span>", "<p><span class=\"bbcode-size-10\">a</span></p>", "it sanitizes spans");
|
||||
});
|
||||
|
||||
test("URLs in BBCode tags", function() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user