forked from github/kensanata.oddmuse
Moved here from ../test.pl
This commit is contained in:
44
t/headers.t
Normal file
44
t/headers.t
Normal file
@@ -0,0 +1,44 @@
|
||||
require 't/test.pl';
|
||||
package OddMuse;
|
||||
use Test::More tests => 13;
|
||||
|
||||
clear_pages();
|
||||
|
||||
# without portrait-support
|
||||
|
||||
# nothing
|
||||
update_page('headers', "== no header ==\n\ntext\n");
|
||||
test_page(get_page('headers'), '== no header ==');
|
||||
|
||||
# usemod only
|
||||
add_module('usemod.pl');
|
||||
update_page('headers', "== is header ==\n\ntext\n");
|
||||
test_page(get_page('headers'), '<h2>is header</h2>');
|
||||
|
||||
# toc + usemod only
|
||||
add_module('toc.pl');
|
||||
update_page('headers', "== one ==\ntext\n== two ==\ntext\n== three ==\ntext\n");
|
||||
test_page(get_page('headers'),
|
||||
'<li><a href="#headers1">one</a></li>',
|
||||
'<li><a href="#headers2">two</a></li>',
|
||||
'<h2 id="headers1">one</h2>',
|
||||
'<h2 id="headers2">two</h2>', );
|
||||
remove_module('usemod.pl');
|
||||
remove_rule(\&UsemodRule);
|
||||
|
||||
# toc + headers
|
||||
add_module('headers.pl');
|
||||
update_page('headers', "one\n===\ntext\ntwo\n---\ntext\nthree\n====\ntext\n");
|
||||
test_page(get_page('headers'),
|
||||
'<li><a href="#headers1">one</a>',
|
||||
'<ol><li><a href="#headers2">two</a></li></ol>',
|
||||
'<li><a href="#headers3">three</a></li>',
|
||||
'<h2 id="headers1">one</h2>',
|
||||
'<h3 id="headers2">two</h3>',
|
||||
'<h2 id="headers3">three</h2>', );
|
||||
remove_module('toc.pl');
|
||||
remove_rule(\&TocRule);
|
||||
|
||||
# headers only
|
||||
update_page('headers', "is header\n=========\n\ntext\n");
|
||||
test_page(get_page('headers'), '<h2>is header</h2>');
|
||||
54
t/hr.t
Normal file
54
t/hr.t
Normal file
@@ -0,0 +1,54 @@
|
||||
require 't/test.pl';
|
||||
package OddMuse;
|
||||
use Test::More tests => 8;
|
||||
|
||||
clear_pages();
|
||||
|
||||
# without portrait-support
|
||||
|
||||
# nothing
|
||||
update_page('hr', "one\n----\ntwo\n");
|
||||
test_page(get_page('hr'), 'one ---- two');
|
||||
|
||||
# usemod only
|
||||
add_module('usemod.pl');
|
||||
update_page('hr', "one\n----\nthree\n");
|
||||
test_page(get_page('hr'),
|
||||
'<div class="content browse"><p>one </p><hr /><p>three</p></div>');
|
||||
remove_rule(\&UsemodRule);
|
||||
|
||||
# headers only
|
||||
add_module('headers.pl');
|
||||
update_page('hr', "one\n----\ntwo\n");
|
||||
test_page(get_page('hr'),
|
||||
'<div class="content browse"><h3>one</h3><p>two</p></div>');
|
||||
|
||||
update_page('hr', "one\n\n----\nthree\n");
|
||||
test_page(get_page('hr'),
|
||||
'<div class="content browse"><p>one</p><hr /><p>three</p></div>');
|
||||
remove_rule(\&HeadersRule);
|
||||
|
||||
# with portrait support
|
||||
|
||||
clear_pages();
|
||||
|
||||
# just portrait-support
|
||||
add_module('portrait-support.pl');
|
||||
update_page('hr', "[new]one\n----\ntwo\n");
|
||||
test_page(get_page('hr'),
|
||||
'<div class="content browse"><div class="color one level0"><p>one </p></div><hr /><p>two</p></div>');
|
||||
|
||||
# usemod and portrait-support
|
||||
add_module('usemod.pl');
|
||||
update_page('hr', "one\n----\nthree\n");
|
||||
test_page(get_page('hr'),
|
||||
'<div class="content browse"><p>one </p><hr /><p>three</p></div>');
|
||||
remove_rule(\&UsemodRule);
|
||||
|
||||
# headers and portrait-support
|
||||
add_module('headers.pl');
|
||||
update_page('hr', "one\n----\ntwo\n");
|
||||
test_page(get_page('hr'), '<div class="content browse"><h3>one</h3><p>two</p></div>');
|
||||
|
||||
update_page('hr', "one\n\n----\nthree\n");
|
||||
test_page(get_page('hr'), '<div class="content browse"><p>one</p><hr /><p>three</p></div>');
|
||||
84
t/links.t
Normal file
84
t/links.t
Normal file
@@ -0,0 +1,84 @@
|
||||
require 't/test.pl';
|
||||
package OddMuse;
|
||||
use Test::More tests => 55;
|
||||
|
||||
clear_pages();
|
||||
add_module('links.pl');
|
||||
|
||||
update_page('InterMap',
|
||||
" Oddmuse http://www.emacswiki.org/cgi-bin/oddmuse.pl?\n",
|
||||
'required', 0, 1);
|
||||
|
||||
update_page('a', 'Oddmuse:foo(no) [Oddmuse:bar] [Oddmuse:baz text] '
|
||||
. '[Oddmuse:bar(no)] [Oddmuse:baz(no) text] '
|
||||
. '[[Oddmuse:foo_(bar)]] [[[Oddmuse:foo (baz)]]] [[Oddmuse:foo (quux)|text]]');
|
||||
$InterInit = 0;
|
||||
InitVariables();
|
||||
|
||||
my @Test = map { quotemeta } split('\n',<<'EOT');
|
||||
"a" -> "Oddmuse:foo"
|
||||
"a" -> "Oddmuse:bar"
|
||||
"a" -> "Oddmuse:baz"
|
||||
"a" -> "Oddmuse:foo_(bar)"
|
||||
"a" -> "Oddmuse:foo (baz)"
|
||||
"a" -> "Oddmuse:foo (quux)"
|
||||
EOT
|
||||
|
||||
test_page_negative(get_page('action=links raw=1'), @Test);
|
||||
test_page(get_page('action=links raw=1 inter=1'), @Test);
|
||||
|
||||
@Test = split('\n',<<'EOT');
|
||||
//a[@class="local"][@href="http://localhost/wiki.pl/a"][text()="a"]
|
||||
//a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?foo"]/span[@class="site"][text()="Oddmuse"]/following-sibling::text()[string()=":"]/following-sibling::span[@class="page"][text()="foo"]
|
||||
//a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?bar"]/span[@class="site"][text()="Oddmuse"]/following-sibling::text()[string()=":"]/following-sibling::span[@class="page"][text()="bar"]
|
||||
//a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?baz"]/span[@class="site"][text()="Oddmuse"]/following-sibling::text()[string()=":"]/following-sibling::span[@class="page"][text()="baz"]
|
||||
//a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?foo_(bar)"]/span[@class="site"][text()="Oddmuse"]/following-sibling::text()[string()=":"]/following-sibling::span[@class="page"][text()="foo_(bar)"]
|
||||
EOT
|
||||
|
||||
negative_xpath_test(get_page('action=links'), @Test);
|
||||
xpath_test(get_page('action=links inter=1'), @Test);
|
||||
|
||||
AppendStringToFile($ConfigFile, "\$BracketWiki = 0;\n");
|
||||
|
||||
update_page('a', '[[b]] [[[c]]] [[d|e]] FooBar [FooBaz] [FooQuux fnord] ');
|
||||
$page = get_page('action=links raw=1');
|
||||
|
||||
test_page($page, split('\n',<<'EOT'));
|
||||
"a" -> "b"
|
||||
"a" -> "c"
|
||||
"a" -> "FooBar"
|
||||
"a" -> "FooBaz"
|
||||
"a" -> "FooQuux"
|
||||
EOT
|
||||
|
||||
test_page_negative($page, '"a" -> "d"');
|
||||
|
||||
AppendStringToFile($ConfigFile, "\$BracketWiki = 1;\n");
|
||||
|
||||
update_page('a', '[[b]] [[[c]]] [[d|e]] FooBar [FooBaz] [FooQuux fnord] '
|
||||
. 'http://www.oddmuse.org/ [http://www.emacswiki.org/] '
|
||||
. '[http://www.communitywiki.org/ cw]');
|
||||
|
||||
@Test1 = split('\n',<<'EOT');
|
||||
"a" -> "b"
|
||||
"a" -> "c"
|
||||
"a" -> "d"
|
||||
"a" -> "FooBar"
|
||||
"a" -> "FooBaz"
|
||||
"a" -> "FooQuux"
|
||||
EOT
|
||||
|
||||
@Test2 = split('\n',<<'EOT');
|
||||
"a" -> "http://www.oddmuse.org/"
|
||||
"a" -> "http://www.emacswiki.org/"
|
||||
"a" -> "http://www.communitywiki.org/"
|
||||
EOT
|
||||
|
||||
$page = get_page('action=links raw=1');
|
||||
test_page($page, @Test1);
|
||||
test_page_negative($page, @Test2);
|
||||
$page = get_page('action=links raw=1 url=1');
|
||||
test_page($page, @Test1, @Test2);
|
||||
$page = get_page('action=links raw=1 links=0 url=1');
|
||||
test_page_negative($page, @Test1);
|
||||
test_page($page, @Test2);
|
||||
26
t/near.t
Normal file
26
t/near.t
Normal file
@@ -0,0 +1,26 @@
|
||||
require 't/test.pl';
|
||||
package OddMuse;
|
||||
use Test::More tests => 5;
|
||||
|
||||
clear_pages();
|
||||
|
||||
CreateDir($NearDir);
|
||||
WriteStringToFile("$NearDir/EmacsWiki", "AlexSchroeder\nFooBar\n");
|
||||
|
||||
update_page('InterMap', " EmacsWiki http://www.emacswiki.org/cgi-bin/wiki/%s\n",
|
||||
'required', 0, 1);
|
||||
update_page('NearMap', " EmacsWiki"
|
||||
. " http://www.emacswiki.org/cgi-bin/emacs?action=index;raw=1"
|
||||
. " http://www.emacswiki.org/cgi-bin/emacs?search=%s;raw=1;near=0\n",
|
||||
'required', 0, 1);
|
||||
|
||||
xpath_test(update_page('FooBaz', "Try FooBar instead!\n"),
|
||||
'//a[@class="near"][@title="EmacsWiki"][@href="http://www.emacswiki.org/cgi-bin/wiki/FooBar"][text()="FooBar"]',
|
||||
'//div[@class="near"]/p/a[@class="local"][@href="http://localhost/wiki.pl/EditNearLinks"][text()="EditNearLinks"]/following-sibling::text()[string()=": "]/following-sibling::a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/wiki.pl?action=edit;id=FooBar"][text()="FooBar"]');
|
||||
|
||||
xpath_test(update_page('FooBar', "Test by AlexSchroeder!\n"),
|
||||
'//div[@class="sister"]/p/a[@title="EmacsWiki:FooBar"][@href="http://www.emacswiki.org/cgi-bin/wiki/FooBar"]/img[@src="file:///tmp/oddmuse/EmacsWiki.png"][@alt="EmacsWiki:FooBar"]');
|
||||
|
||||
xpath_test(get_page('search=alexschroeder'),
|
||||
'//p[text()="Near pages:"]',
|
||||
'//a[@class="near"][@title="EmacsWiki"][@href="http://www.emacswiki.org/cgi-bin/wiki/AlexSchroeder"][text()="AlexSchroeder"]');
|
||||
62
t/portrait.t
Normal file
62
t/portrait.t
Normal file
@@ -0,0 +1,62 @@
|
||||
require 't/test.pl';
|
||||
package OddMuse;
|
||||
use Test::More tests => 18;
|
||||
|
||||
clear_pages();
|
||||
add_module('portrait-support.pl');
|
||||
|
||||
# nothing
|
||||
update_page('headers', "[new]foo\n== no header ==\n\ntext\n");
|
||||
test_page(get_page('headers'),
|
||||
'<div class="color one level0"><p>foo == no header ==</p><p>text</p></div>');
|
||||
|
||||
# usemod only
|
||||
add_module('usemod.pl');
|
||||
update_page('headers', "[new]foo\n== is header ==\n\ntext\n");
|
||||
test_page(get_page('headers'), '<div class="color one level0"><p>foo </p></div><h2>is header</h2>');
|
||||
|
||||
# usemod + toc only
|
||||
add_module('toc.pl');
|
||||
update_page('headers',
|
||||
"[new]foo\n== one ==\ntext\n== two ==\ntext\n== three ==\ntext\n");
|
||||
test_page(get_page('headers'),
|
||||
# default to before the header
|
||||
'<div class="content browse"><div class="color one level0"><p>foo </p></div>',
|
||||
'<div class="toc"><h2>Contents</h2><ol>',
|
||||
'<li><a href="#headers1">one</a></li>',
|
||||
'<li><a href="#headers2">two</a></li>',
|
||||
'<li><a href="#headers3">three</a></li></ol></div>',
|
||||
'<h2 id="headers1">one</h2><p>text </p>',
|
||||
'<h2 id="headers2">two</h2>', );
|
||||
remove_module('toc.pl');
|
||||
remove_rule(\&TocRule);
|
||||
remove_module('usemod.pl');
|
||||
remove_rule(\&UsemodRule);
|
||||
|
||||
# headers only
|
||||
add_module('headers.pl');
|
||||
update_page('headers', "[new]foo\nis header\n=========\n\ntext\n");
|
||||
test_page(get_page('headers'), '<div class="color one level0"><p>foo </p></div><h2>is header</h2>');
|
||||
remove_module('headers.pl');
|
||||
remove_rule(\&HeadersRule);
|
||||
|
||||
# portrait-support, toc, and usemod
|
||||
|
||||
add_module('usemod.pl');
|
||||
add_module('toc.pl');
|
||||
update_page('headers', "[new]foo\n== one ==\ntext\n== two ==\ntext\n== three ==\ntext\n");
|
||||
test_page(get_page('headers'),
|
||||
'<li><a href="#headers1">one</a></li>',
|
||||
'<li><a href="#headers2">two</a></li>',
|
||||
'<div class="color one level0"><p>foo </p></div>',
|
||||
'<h2 id="headers1">one</h2>',
|
||||
'<h2 id="headers2">two</h2>', );
|
||||
|
||||
run_tests(split('\n',<<'EOT'));
|
||||
[new]\nfoo
|
||||
<div class="color one level0"><p> foo</p></div>
|
||||
:[new]\nfoo
|
||||
<div class="color two level1"><p> foo</p></div>
|
||||
::[new]\nfoo
|
||||
<div class="color one level2"><p> foo</p></div>
|
||||
EOT
|
||||
69
t/sidebar.t
Normal file
69
t/sidebar.t
Normal file
@@ -0,0 +1,69 @@
|
||||
require 't/test.pl';
|
||||
package OddMuse;
|
||||
use Test::More tests => 17;
|
||||
|
||||
clear_pages();
|
||||
|
||||
add_module('sidebar.pl');
|
||||
|
||||
test_page(update_page('SideBar', 'mu'), '<div class="sidebar"><p>mu</p></div>');
|
||||
test_page(get_page('HomePage'), '<div class="sidebar"><p>mu</p></div>');
|
||||
|
||||
# with toc
|
||||
|
||||
add_module('toc.pl');
|
||||
add_module('usemod.pl');
|
||||
|
||||
AppendStringToFile($ConfigFile, "\$TocAutomatic = 0;\n");
|
||||
|
||||
update_page('SideBar', "bla\n\n"
|
||||
. "== mu ==\n\n"
|
||||
. "bla");
|
||||
|
||||
test_page(update_page('test', "bla\n"
|
||||
. "<toc>\n"
|
||||
. "murks\n"
|
||||
. "==two=\n"
|
||||
. "bla\n"
|
||||
. "===three==\n"
|
||||
. "bla\n"
|
||||
. "=one=\n"),
|
||||
quotemeta('<ol><li><a href="#test1">two</a><ol><li><a href="#test2">three</a></li></ol></li><li><a href="#test3">one</a></li></ol>'),
|
||||
quotemeta('<h2 id="SideBar1">mu</h2>'),
|
||||
quotemeta('<h2 id="test1">two</h2>'),
|
||||
quotemeta('<h2 id="test3">one</h2>'),
|
||||
quotemeta('bla </p><div class="toc"><h2>Contents</h2><ol><li><a '),
|
||||
quotemeta('one</a></li></ol></div><p> murks'));
|
||||
|
||||
update_page('SideBar', "<toc>");
|
||||
test_page(update_page('test', "bla\n"
|
||||
. "murks\n"
|
||||
. "==two=\n"
|
||||
. "bla\n"
|
||||
. "===three==\n"
|
||||
. "bla\n"
|
||||
. "=one=\n"),
|
||||
quotemeta('<ol><li><a href="#test1">two</a><ol><li><a href="#test2">three</a></li></ol></li><li><a href="#test3">one</a></li></ol>'),
|
||||
quotemeta('<h2 id="test1">two</h2>'),
|
||||
quotemeta('<h2 id="test3">one</h2>'),
|
||||
quotemeta('<div class="sidebar"><div class="toc"><h2>Contents</h2><ol><li><a '),
|
||||
quotemeta('one</a></li></ol></div></div><div class="content browse"><p>'));
|
||||
|
||||
remove_rule(\&TocRule);
|
||||
remove_rule(\&UsemodRule);
|
||||
|
||||
# with forms
|
||||
|
||||
add_module('forms.pl');
|
||||
|
||||
test_page(update_page('SideBar', '<form><h1>mu</h1></form>'),
|
||||
'<div class="sidebar"><p><form><h1>mu</h1></form></p></div>');
|
||||
xpath_test(get_page('action=pagelock id=SideBar set=1 pwd=foo'),
|
||||
'//p/text()[string()="Lock for "]/following-sibling::a[@href="http://localhost/wiki.pl/SideBar"][@class="local"][text()="SideBar"]/following-sibling::text()[string()=" created."]');
|
||||
test_page(get_page('SideBar'), '<div class="sidebar"><form><h1>mu</h1></form></div>');
|
||||
# While rendering the SideBar as part of the HomePage, it should still
|
||||
# be considered "locked", and therefore the form should render
|
||||
# correctly.
|
||||
test_page(get_page('HomePage'),
|
||||
'<div class="sidebar"><form><h1>mu</h1></form></div>');
|
||||
# test_page(get_page('HomePage'), '<div class="sidebar"><p><form><h1>mu</h1></form></p></div>');
|
||||
94
t/toc.t
Normal file
94
t/toc.t
Normal file
@@ -0,0 +1,94 @@
|
||||
require 't/test.pl';
|
||||
package OddMuse;
|
||||
use Test::More tests => 22;
|
||||
|
||||
clear_pages();
|
||||
|
||||
add_module('toc.pl');
|
||||
add_module('usemod.pl');
|
||||
|
||||
InitVariables(); # do this after loading usemod.pl!
|
||||
|
||||
run_tests(split('\n',<<'EOT'));
|
||||
== make honey ==\n\nMoo.\n
|
||||
<h2 id="toc1">make honey</h2><p>Moo.</p>
|
||||
EOT
|
||||
|
||||
test_page(update_page('toc', "bla\n"
|
||||
. "=one=\n"
|
||||
. "blarg\n"
|
||||
. "==two==\n"
|
||||
. "bla\n"
|
||||
. "==two==\n"
|
||||
. "mu."),
|
||||
quotemeta('<ol><li><a href="#toc1">one</a><ol><li><a href="#toc2">two</a></li><li><a href="#toc3">two</a></li></ol></li></ol>'),
|
||||
quotemeta('<h2 id="toc1">one</h2>'),
|
||||
quotemeta('<h2 id="toc2">two</h2>'),
|
||||
quotemeta('bla </p><div class="toc"><h2>Contents</h2><ol><li><a '),
|
||||
quotemeta('two</a></li></ol></li></ol></div><h2 id="toc1">one</h2>'),);
|
||||
|
||||
test_page(update_page('toc', "bla\n"
|
||||
. "==two=\n"
|
||||
. "bla\n"
|
||||
. "===three==\n"
|
||||
. "bla\n"
|
||||
. "==two==\n"),
|
||||
quotemeta('<ol><li><a href="#toc1">two</a><ol><li><a href="#toc2">three</a></li></ol></li><li><a href="#toc3">two</a></li></ol>'),
|
||||
quotemeta('<h2 id="toc1">two</h2>'),
|
||||
quotemeta('<h3 id="toc2">three</h3>'));
|
||||
|
||||
test_page(update_page('toc', "bla\n"
|
||||
. "<toc>\n"
|
||||
. "murks\n"
|
||||
. "==two=\n"
|
||||
. "bla\n"
|
||||
. "===three==\n"
|
||||
. "bla\n"
|
||||
. "=one=\n"),
|
||||
quotemeta('<ol><li><a href="#toc1">two</a><ol><li><a href="#toc2">three</a></li></ol></li><li><a href="#toc3">one</a></li></ol>'),
|
||||
quotemeta('<h2 id="toc1">two</h2>'),
|
||||
quotemeta('<h2 id="toc3">one</h2>'),
|
||||
quotemeta('bla </p><div class="toc"><h2>Contents</h2><ol><li><a '),
|
||||
quotemeta('one</a></li></ol></div><p> murks'),);
|
||||
|
||||
test_page(update_page('toc', "bla\n"
|
||||
. "=one=\n"
|
||||
. "blarg\n"
|
||||
. "==two==\n"
|
||||
. "<nowiki>bla\n"
|
||||
. "==two==\n"
|
||||
. "mu.</nowiki>\n"
|
||||
. "<nowiki>bla\n"
|
||||
. "==two==\n"
|
||||
. "mu.</nowiki>\n"
|
||||
. "yadda <code>bla\n"
|
||||
. "==two==\n"
|
||||
. "mu.</code>\n"
|
||||
. "yadda <pre> has no effect! \n"
|
||||
. "##bla\n"
|
||||
. "==three==\n"
|
||||
. "mu.##\n"
|
||||
. "=one=\n"
|
||||
. "blarg </pre>\n"),
|
||||
quotemeta('<ol><li><a href="#toc1">one</a><ol><li><a href="#toc2">two</a></li><li><a href="#toc3">three</a></li></ol></li><li><a href="#toc4">one</a></li></ol>'),
|
||||
quotemeta('<h2 id="toc1">one</h2>'),
|
||||
quotemeta('<h2 id="toc2">two</h2>'),
|
||||
quotemeta('<h2 id="toc3">three</h2>'),
|
||||
quotemeta('<h2 id="toc4">one</h2>'),);
|
||||
|
||||
add_module('markup.pl');
|
||||
|
||||
test_page(update_page('toc', "bla\n"
|
||||
. "=one=\n"
|
||||
. "blarg\n"
|
||||
. "<code>bla\n"
|
||||
. "=two=\n"
|
||||
. "mu.</code>\n"
|
||||
. "##bla\n"
|
||||
. "=three=\n"
|
||||
. "mu.##\n"
|
||||
. "=four=\n"
|
||||
. "blarg\n"),
|
||||
quotemeta('<ol><li><a href="#toc1">one</a></li><li><a href="#toc2">four</a></li></ol>'),
|
||||
quotemeta('<h2 id="toc1">one</h2>'),
|
||||
quotemeta('<h2 id="toc2">four</h2>'),);
|
||||
Reference in New Issue
Block a user