]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - t/pagename.t
Merge branch 'master' of git://git.ikiwiki.info
[git.ikiwiki.info.git] / t / pagename.t
index c7f1ce1801d92ee470f901e7f9f1eca35a6fa6fb..540d10f4c0bcc4a4a020674a0574e89ce42b3214 100755 (executable)
@@ -1,14 +1,35 @@
 #!/usr/bin/perl
 use warnings;
 use strict;
 #!/usr/bin/perl
 use warnings;
 use strict;
-use Test::More tests => 5;
+use Test::More tests => 19;
 
 BEGIN { use_ok("IkiWiki"); }
 
 
 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(pagename("foo.mdwn"), "foo");
+is(pagetype("foo/bar.mdwn"), "mdwn");
 is(pagename("foo/bar.mdwn"), "foo/bar");
 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(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");
 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");