From b2f2e7b1d2a2fcc4500b435d06a0690d8a6e8976 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 25 Jul 2014 15:59:16 -0400 Subject: [PATCH] REFACTOR: Move Markdown tests to Javascript land --- spec/components/pretty_text_spec.rb | 39 --------------------------- test/javascripts/lib/markdown_test.js | 20 +++++++++++--- 2 files changed, 17 insertions(+), 42 deletions(-) diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index 3dc0e9fbb43..594257ef3cc 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -266,43 +266,4 @@ describe PrettyText do end end - describe "markdown quirks" do - - it "sanitizes spans" do - PrettyText.cook("a").should match_html "

a

" - PrettyText.cook("a").should match_html "

a

" - PrettyText.cook("a").should match_html "

a

" - end - - it "bolds stuff in parens" do - PrettyText.cook("a \"**hello**\"").should match_html "

a "hello"

" - PrettyText.cook("(**hello**)").should match_html "

(hello)

" - # is it me your looking for? - end - it "allows for newline after bold" do - PrettyText.cook("**hello**\nworld").should match_html "

hello
world

" - end - it "allows for newline for 2 bolds" do - PrettyText.cook("**hello**\n**world**").should match_html "

hello
world

" - end - - it "allows for * and _ in bold" do - PrettyText.cook("**a*_b**").should match_html "

a*_b

" - end - - it "does not apply italics when there is a space inside" do - PrettyText.cook("** hello**").should match_html "

** hello**

" - PrettyText.cook("**hello **").should match_html "

**hello **

" - end - - it "allows does not bold chinese intra word" do - PrettyText.cook("你**hello**").should match_html "

你**hello**

" - end - - it "allows bold chinese" do - PrettyText.cook("**你hello**").should match_html "

你hello

" - end - - end - end diff --git a/test/javascripts/lib/markdown_test.js b/test/javascripts/lib/markdown_test.js index 7a961900b71..2182dfe56e0 100644 --- a/test/javascripts/lib/markdown_test.js +++ b/test/javascripts/lib/markdown_test.js @@ -261,9 +261,19 @@ test("Mentions", function() { test("Heading", function() { - cooked("**Bold**\n----------", - "

Bold

", - "It will bold the heading"); + cooked("**Bold**\n----------", "

Bold

", "It will bold the heading"); +}); + +test("bold and italics", function() { + cooked("a \"**hello**\"", "

a \"hello\"

", "bolds in quotes"); + cooked("(**hello**)", "

(hello)

", "bolds in parens"); + cooked("**hello**\nworld", "

hello
world

", "allows newline after bold"); + cooked("**hello**\n**world**", "

hello
world

", "newline between two bolds"); + cooked("**a*_b**", "

a*_b

", "allows for characters within bold"); + cooked("** hello**", "

** hello**

", "does not bold on a space boundary"); + cooked("**hello **", "

**hello **

", "does not bold on a space boundary"); + cooked("你**hello**", "

你**hello**

", "does not bold chinese intra word"); + cooked("**你hello**", "

你hello

", "allows bolded chinese"); }); test("Oneboxing", function() { @@ -388,6 +398,10 @@ test("sanitize", function() { cooked("[the answer](javascript:alert(42))", "

the answer

", "it prevents XSS"); cooked("\n", "


", "it doesn't circumvent XSS with comments"); + + cooked("a", "

a

", "it sanitizes spans"); + cooked("a", "

a

", "it sanitizes spans"); + cooked("a", "

a

", "it sanitizes spans"); }); test("URLs in BBCode tags", function() {