]> scripts.mit.edu Git - www/ikiwiki.git/blobdiff - t/po.t
po(mybestlink): fixed when fed with path beginning with /
[www/ikiwiki.git] / t / po.t
diff --git a/t/po.t b/t/po.t
index 3074372d309288ee19a9fbca59bf102e1122266c..79e087318ed6d2dbc7069ef2a690cf375a2ab26a 100755 (executable)
--- a/t/po.t
+++ b/t/po.t
@@ -17,7 +17,7 @@ BEGIN {
        }
 }
 
-use Test::More tests => 52;
+use Test::More tests => 59;
 
 BEGIN { use_ok("IkiWiki"); }
 
@@ -122,8 +122,6 @@ is_deeply(\@{$links{'nontranslatable'}}, ['/', 'translatable', 'translatable.fr'
 $config{po_link_to}='current';
 $msgprefix="links (po_link_to=current)";
 refresh_n_scan('index.mdwn', 'translatable.mdwn', 'nontranslatable.mdwn');
-use Data::Dumper;
-print Dumper(%links);
 is_deeply(\@{$links{'index'}}, ['translatable', 'nontranslatable'], "$msgprefix index");
 is_deeply(\@{$links{'index.es'}}, [ map bestlink('index.es', $_), ('translatable.es', 'nontranslatable')], "$msgprefix index.es");
 is_deeply(\@{$links{'index.fr'}}, [ map bestlink('index.fr', $_), ('translatable.fr', 'nontranslatable')], "$msgprefix index.fr");
@@ -146,6 +144,18 @@ is(targetpage('test1.fr', 'html'), 'test1/index.fr.html', "$msgprefix test1.fr")
 is(targetpage('test3', 'html'), 'test3/index.html', "$msgprefix test3 (non-translatable page)");
 is(targetpage('test3.es', 'html'), 'test3.es/index.html', "$msgprefix test3.es (non-translatable page)");
 
+### urlto -> index
+$config{po_link_to}='current';
+$msgprefix="urlto (po_link_to=current)";
+is(urlto('', 'index'), './index.en.html', "$msgprefix index -> ''");
+is(urlto('', 'nontranslatable'), './../index.en.html', "$msgprefix nontranslatable -> ''");
+is(urlto('', 'translatable.fr'), './../index.fr.html', "$msgprefix translatable.fr -> ''");
+$config{po_link_to}='negotiated';
+$msgprefix="urlto (po_link_to=negotiated)";
+is(urlto('', 'index'), './', "$msgprefix index -> ''");
+is(urlto('', 'nontranslatable'), './../', "$msgprefix nontranslatable -> ''");
+is(urlto('', 'translatable.fr'), './../', "$msgprefix translatable.fr -> ''");
+
 ### bestlink
 $config{po_link_to}='current';
 $msgprefix="bestlink (po_link_to=current)";
@@ -153,7 +163,7 @@ is(bestlink('test1.fr', 'test2'), 'test2.fr', "$msgprefix test1.fr -> test2");
 is(bestlink('test1.fr', 'test2.es'), 'test2.es', "$msgprefix test1.fr -> test2.es");
 $config{po_link_to}='negotiated';
 $msgprefix="bestlink (po_link_to=negotiated)";
-is(bestlink('test1.fr', 'test2'), 'test2', "$msgprefix test1.fr -> test2");
+is(bestlink('test1.fr', 'test2'), 'test2.fr', "$msgprefix test1.fr -> test2");
 is(bestlink('test1.fr', 'test2.es'), 'test2.es', "$msgprefix test1.fr -> test2.es");
 
 ### beautify_urlpath
@@ -163,5 +173,6 @@ is(IkiWiki::beautify_urlpath('test1/index.en.html'), './test1/index.en.html', "$
 is(IkiWiki::beautify_urlpath('test1/index.fr.html'), './test1/index.fr.html', "$msgprefix test1/index.fr.html");
 $config{po_link_to}='negotiated';
 $msgprefix="beautify_urlpath (po_link_to=negotiated)";
+is(IkiWiki::beautify_urlpath('test1/index.html'), './test1/', "$msgprefix test1/index.html");
 is(IkiWiki::beautify_urlpath('test1/index.en.html'), './test1/', "$msgprefix test1/index.en.html");
-is(IkiWiki::beautify_urlpath('test1/index.fr.html'), './test1/index.fr.html', "$msgprefix test1/index.fr.html");
+is(IkiWiki::beautify_urlpath('test1/index.fr.html'), './test1/', "$msgprefix test1/index.fr.html");