test/wiki_cloth_test.rb in wikicloth-0.6.1 vs test/wiki_cloth_test.rb in wikicloth-0.6.2
- old
+ new
@@ -25,15 +25,63 @@
class WikiClothTest < ActiveSupport::TestCase
test "links and references" do
wiki = WikiCloth::Parser.new(:data => File.open(File.join(File.dirname(__FILE__), '../sample_documents/george_washington.wiki'), READ_MODE) { |f| f.read })
data = wiki.to_html
- assert wiki.external_links.size == 62
+ assert wiki.external_links.size == 41
assert wiki.references.size == 76
assert wiki.internal_links.size == 560
end
+ test "behavior switch should not show up in the html output" do
+ wiki = WikiParser.new(:data => "__NOTOC__hello world")
+ data = wiki.to_html
+ assert data !~ /TOC/
+ end
+
+ test "template vars should not be parsed inside a pre tag" do
+ wiki = WikiCloth::Parser.new(:data => "<pre>{{{1}}}</pre>")
+ data = wiki.to_html
+ assert data =~ /{{{1}}}/
+ end
+
+ test "[[ links ]] should not work inside pre tags" do
+ data = <<EOS
+Now instead of calling WikiCloth::Parser directly call your new class.
+
+<pre> @wiki = WikiParser.new({
+ :params => { "PAGENAME" => "Testing123" },
+ :data => "[[test]] {{hello|world}} From {{ PAGENAME }} -- [www.google.com]"
+ })
+
+ @wiki.to_html</pre>
+EOS
+ wiki = WikiCloth::Parser.new(:data => data)
+ data = wiki.to_html
+ assert data !~ /href/
+ assert data !~ /\{/
+ assert data !~ /\]/
+ end
+
+ test "external links without a http:// prefix" do
+ wiki = WikiCloth::Parser.new(:data => "[www.google.com]")
+ data = wiki.to_html
+ assert data =~ /http/
+ end
+
+ test "auto pre at end of document" do
+ wiki = WikiParser.new(:data => "test\n\n hello\n world\nend")
+ data = wiki.to_html
+ assert data =~ /hello/
+ assert data =~ /world/
+
+ wiki = WikiParser.new(:data => "test\n\n hello\n world")
+ data = wiki.to_html
+ assert data =~ /hello/
+ assert data =~ /world/
+ end
+
test "template params" do
wiki = WikiParser.new(:data => "{{testparams|test|test=bla|it worked|bla=whoo}}\n")
data = wiki.to_html
assert data =~ /hello world/
assert data =~ /test/
@@ -100,11 +148,10 @@
test "sanitize html" do
wiki = WikiParser.new(:data => "<script type=\"text/javascript\" src=\"bla.js\"></script>\n<a href=\"test.html\" onmouseover=\"alert('hello world');\">test</a>\n")
data = wiki.to_html
assert !(data =~ /<script/)
assert !(data =~ /onmouseover/)
- assert data =~ /exlink/
end
test "nowiki and code tags" do
wiki = WikiParser.new(:data => "<nowiki>{{test}}</nowiki><code>{{test}}</code>{{nowiki}}\n")
data = wiki.to_html
@@ -113,13 +160,13 @@
end
test "disable edit stuff" do
wiki = WikiParser.new(:data => "= Hallo =")
data = wiki.to_html
- assert_equal data, "<p>\n<h1><span class=\"editsection\">[<a href=\"?section=Hallo\" target=\"_blank\" class=\"exlink\">edit</a>]</span> <span class=\"mw-headline\" id=\"Hallo\">Hallo</span></h1>\n</p>"
+ assert_equal data, "<p>\n<h1><span class=\"editsection\">[<a href=\"?section=Hallo\" title=\"Edit section: Hallo\">edit</a>]</span> <span class=\"mw-headline\" id=\"Hallo\"><a name=\"Hallo\">Hallo</a></span></h1>\n</p>"
data = wiki.to_html(:noedit => true)
- assert_equal data, "<p>\n<h1><span class=\"mw-headline\" id=\"Hallo\">Hallo</span></h1>\n</p>"
+ assert_equal data, "<p>\n<h1><span class=\"mw-headline\" id=\"Hallo\"><a name=\"Hallo\">Hallo</a></span></h1>\n</p>"
end
end