require 'test_helper' require 'flannel/stripe' class HtmlFormatterTest < Test::Unit::TestCase context "basic operations" do setup do @formatter = Flannel::HtmlFormatter.new end should "return html fragment with format" do assert_equal "
foo
", @formatter.do('foo', :paragraph) end context "subdirectories" do should "handle subdirectories and not display directory info" do result = @formatter.do("I think it -cheese/tastes good>.", :paragraph) assert_equal 'I think it tastes good.
', result end end context "links" do should "output the link" do assert_equal '', @formatter.do("-cheese>", :paragraph) end should "hyphenate words" do result = @formatter.do("-cheese is good>", :paragraph) assert_equal '', result end should "replace text surrounded by - and > with a wiki link" do result = @formatter.do("red, -green>, refactor", :paragraph) assert_equal 'red, green, refactor
',result end should "not replace text surrounded by - and > with a wiki link if spaced" do result = @formatter.do("red, - green >, refactor", :paragraph) assert_equal 'red, - green >, refactor
', result end should "not replace text surrounded by - and > with a wiki link if spaced on right" do result = @formatter.do("red, -green >, refactor", :paragraph) assert_equal 'red, -green >, refactor
', result end should "not replace surrounded by - and > with a wiki link if spaced on left" do result = @formatter.do("red, - green>, refactor", :paragraph) assert_equal 'red, - green>, refactor
', result end end context "preformatted text" do should "html escape preformatted text" do result = @formatter.do("& foo
", :preformatted) assert_equal "<p>& foo</p>", result end end context "making permalinks" do should "replace spaces with dashes" do assert_equal "get-the-box", @formatter.permalink("get the box") end should "replace multiple spaces with single dashes" do assert_equal "get-the-box", @formatter.permalink("get the box") end should "replace odd characters with dashes" do assert_equal "get-the-box", @formatter.permalink("get the @#)(* box") end should "not be greedy in matching" do result = @formatter.do "a -foo> and a -bar>.", :paragraph assert_equal '', result end end end end