summaryrefslogtreecommitdiff
path: root/t/pagename.t
blob: 540d10f4c0bcc4a4a020674a0574e89ce42b3214 (plain)
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. use Test::More tests => 19;
  5. BEGIN { use_ok("IkiWiki"); }
  6. # define mdwn as an extension
  7. $IkiWiki::hooks{htmlize}{mdwn}={};
  8. is(pagetype("foo.mdwn"), "mdwn");
  9. is(pagename("foo.mdwn"), "foo");
  10. is(pagetype("foo/bar.mdwn"), "mdwn");
  11. is(pagename("foo/bar.mdwn"), "foo/bar");
  12. # bare files get the full filename as page name, undef type
  13. is(pagetype("foo.png"), undef);
  14. is(pagename("foo.png"), "foo.png");
  15. is(pagetype("foo/bar.png"), undef);
  16. is(pagename("foo/bar.png"), "foo/bar.png");
  17. is(pagetype("foo"), undef);
  18. is(pagename("foo"), "foo");
  19. # keepextension preserves the extension in the page name
  20. $IkiWiki::hooks{htmlize}{txt}={keepextension => 1};
  21. is(pagename("foo.txt"), "foo.txt");
  22. is(pagetype("foo.txt"), "txt");
  23. is(pagename("foo/bar.txt"), "foo/bar.txt");
  24. is(pagetype("foo/bar.txt"), "txt");
  25. # noextension makes extensionless files be treated as first-class pages
  26. $IkiWiki::hooks{htmlize}{Makefile}={noextension =>1};
  27. is(pagetype("Makefile"), "Makefile");
  28. is(pagename("Makefile"), "Makefile");
  29. is(pagetype("foo/Makefile"), "Makefile");
  30. is(pagename("foo/Makefile"), "foo/Makefile");