summaryrefslogtreecommitdiff
path: root/t/pagename.t
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2009-03-08 09:50:27 +0100
committerintrigeri <intrigeri@boum.org>2009-03-08 09:50:27 +0100
commitae474d8e14631ff519ed7d54bb64eaa0538f56d9 (patch)
tree09637db5faf2632b67b581cf04463fe4493584d4 /t/pagename.t
parent0314ed459ba1c49fad9170a54cc05f1c9e9c96bf (diff)
parent08e4472fc469c630ebef93e16a66a5a69d9cb33a (diff)
Merge commit 'upstream/master' into prv/po
Conflicts: IkiWiki/Plugin/editpage.pm debian/control debian/copyright doc/todo/need_global_renamepage_hook.mdwn Signed-off-by: intrigeri <intrigeri@boum.org>
Diffstat (limited to 't/pagename.t')
-rwxr-xr-xt/pagename.t29
1 files changed, 25 insertions, 4 deletions
diff --git a/t/pagename.t b/t/pagename.t
index c7f1ce180..540d10f4c 100755
--- a/t/pagename.t
+++ b/t/pagename.t
@@ -1,14 +1,35 @@
#!/usr/bin/perl
use warnings;
use strict;
-use Test::More tests => 5;
+use Test::More tests => 19;
BEGIN { use_ok("IkiWiki"); }
-# Used internally.
-$IkiWiki::hooks{htmlize}{mdwn}{call}=sub {};
-
+# define mdwn as an extension
+$IkiWiki::hooks{htmlize}{mdwn}={};
+is(pagetype("foo.mdwn"), "mdwn");
is(pagename("foo.mdwn"), "foo");
+is(pagetype("foo/bar.mdwn"), "mdwn");
is(pagename("foo/bar.mdwn"), "foo/bar");
+
+# bare files get the full filename as page name, undef type
+is(pagetype("foo.png"), undef);
is(pagename("foo.png"), "foo.png");
+is(pagetype("foo/bar.png"), undef);
+is(pagename("foo/bar.png"), "foo/bar.png");
+is(pagetype("foo"), undef);
is(pagename("foo"), "foo");
+
+# keepextension preserves the extension in the page name
+$IkiWiki::hooks{htmlize}{txt}={keepextension => 1};
+is(pagename("foo.txt"), "foo.txt");
+is(pagetype("foo.txt"), "txt");
+is(pagename("foo/bar.txt"), "foo/bar.txt");
+is(pagetype("foo/bar.txt"), "txt");
+
+# noextension makes extensionless files be treated as first-class pages
+$IkiWiki::hooks{htmlize}{Makefile}={noextension =>1};
+is(pagetype("Makefile"), "Makefile");
+is(pagename("Makefile"), "Makefile");
+is(pagetype("foo/Makefile"), "Makefile");
+is(pagename("foo/Makefile"), "foo/Makefile");