9 BEGIN { use_ok("IkiWiki"); }
10 BEGIN { use_ok("IkiWiki::Render"); }
11 BEGIN { use_ok("IkiWiki::Plugin::map"); }
12 BEGIN { use_ok("IkiWiki::Plugin::mdwn"); }
14 ok(! system("rm -rf t/tmp; mkdir t/tmp"));
17 $config{srcdir} = 't/tmp';
18 $config{underlaydir} = 't/tmp';
19 $config{underlaydirbase} = '.';
20 $config{templatedir} = 'templates';
22 $config{htmlext} = 'html';
23 $config{wiki_file_chars} = "-[:alnum:]+/.:_";
24 $config{userdir} = "users";
25 $config{tagbase} = "tags";
26 $config{default_pageext} = "mdwn";
27 $config{wiki_file_prune_regexps} = [qr/^\./];
28 $config{autoindex_commit} = 0;
32 %oldrenderedfiles=%pagectime=();
33 %pagesources=%pagemtime=%oldlinks=%links=%depends=%typedlinks=%oldtypedlinks=
34 %destsources=%renderedfiles=%pagecase=%pagestate=();
50 foreach my $page (@pages) {
51 # we use a non-default extension for these, so they're distinguishable
52 # from programmatically-created pages
53 $pagesources{$page} = "$page.mdwn";
54 $destsources{$page} = "$page.mdwn";
55 $pagemtime{$page} = $pagectime{$page} = 1000000;
56 writefile("$page.mdwn", "t/tmp", "your ad here");
70 return { %stuff, name => $name, kids => $kids };
79 # expected is a list of hashes
81 foreach my $li ($ul->children) {
82 my @kids = $li->children;
86 my $expectation = shift @$expected;
88 is($kids[0]->tag, 'a');
91 if ($expectation->{parent}) {
92 is($a->att('class'), 'mapparent');
95 is($a->att('class'), 'mapitem');
98 is_deeply([$a->text], [$expectation->{name}]);
100 if (@{$expectation->{kids}}) {
103 check_nodes($kids[1], $expectation->{kids});
106 is_deeply([@kids], [$a]);
112 my $pagespec = shift;
113 my $expected = shift;
114 comment("*** $pagespec ***\n");
116 my $html = IkiWiki::Plugin::map::preprocess(pages => $pagespec,
120 my $tree = XML::Twig->new(pretty_print => 'indented');
125 print "malformed XML: $@\n$html\n";
128 my $fragment = $tree->root;
130 is($fragment->tag, 'div');
131 is($fragment->att('class'), 'map');
134 check_nodes(($fragment->children)[0], $expected);
137 ok(! $fragment->children);
143 check('doesnotexist', []);
145 check('alpha', [node('alpha', [])]);
162 check('alpha or alpha/*',
179 check('alpha or alpha/1 or beta',
187 check('alpha/1 or beta',
195 check('alpha/1/i* or alpha/2/a or beta',
211 check('alpha/1/i* or alpha/2/a',
232 ok(! system("rm -rf t/tmp"));