aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2017-05-16 08:52:39 +0100
committerSimon McVittie <smcv@debian.org>2017-05-16 08:55:24 +0100
commit77df914b3af94cae62201bdc945fdddd639b1929 (patch)
treed95e75566599d76ea8c4e66ae7975de8db639567 /t
parent787fb8b058fe4e00132e13c48ef777a9928849a4 (diff)
downloadikiwiki-77df914b3af94cae62201bdc945fdddd639b1929.tar
ikiwiki-77df914b3af94cae62201bdc945fdddd639b1929.tar.gz
Add a simple unit test for [[!toc]]
Diffstat (limited to 't')
-rwxr-xr-xt/toc.t42
1 files changed, 42 insertions, 0 deletions
diff --git a/t/toc.t b/t/toc.t
new file mode 100755
index 000000000..ff8e9f991
--- /dev/null
+++ b/t/toc.t
@@ -0,0 +1,42 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use Test::More;
+use Encode;
+
+BEGIN { use_ok("IkiWiki"); }
+BEGIN { use_ok("IkiWiki::Render"); }
+
+%config=IkiWiki::defaultconfig();
+$config{srcdir}=$config{destdir}="/dev/null";
+$config{add_plugins}=[qw(toc)];
+IkiWiki::loadplugins();
+IkiWiki::checkconfig();
+
+sub render {
+ my $content = shift;
+ $IkiWiki::pagesources{foo} = "foo.mdwn";
+ $IkiWiki::pagemtime{foo} = 42;
+ $IkiWiki::pagectime{foo} = 42;
+ $content = IkiWiki::filter("foo", "foo", $content);
+ $content = IkiWiki::preprocess("foo", "foo", $content);
+ $content = IkiWiki::linkify("foo", "foo", $content);
+ $content = IkiWiki::htmlize("foo", "foo", "mdwn", $content);
+ $content = IkiWiki::genpage("foo", $content);
+ return $content;
+}
+
+# https://ikiwiki.info/todo/toc-with-human-readable-anchors/
+# (toc-recycle-id part)
+like(render('[[!toc ]]
+## Weasels
+
+These mustelids are weasilly recognised
+
+<h2 id="the-chapter-on-stoats">Stoats</h2>
+
+These are stoatally different
+'),
+ qr{(?s)<a href="\#index1h2">.*<a href="\#the-chapter-on-stoats">});
+
+done_testing();