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");
64 return { %stuff, name => $name, kids => $kids };
73 # expected is a list of hashes
75 foreach my $li ($ul->children) {
76 my @kids = $li->children;
80 my $expectation = shift @$expected;
82 is($kids[0]->tag, 'a');
85 if ($expectation->{parent}) {
86 is($a->att('class'), 'mapparent');
89 is($a->att('class'), 'mapitem');
92 is_deeply([$a->text], [$expectation->{name}]);
94 if (@{$expectation->{kids}}) {
97 check_nodes($kids[1], $expectation->{kids});
100 is_deeply([@kids], [$a]);
106 my $pagespec = shift;
107 my $expected = shift;
108 print "*** $pagespec ***\n";
110 my $html = IkiWiki::Plugin::map::preprocess(pages => $pagespec,
113 my $tree = XML::Twig->new(pretty_print => 'indented');
118 print "malformed XML: $@\n$html\n";
121 my $fragment = $tree->root;
123 is($fragment->tag, 'div');
124 is($fragment->att('class'), 'map');
127 check_nodes(($fragment->children)[0], $expected);
130 ok(! $fragment->children);
137 check('doesnotexist', []);
139 check('alpha', [node('alpha', [])]);
156 check('alpha or alpha/*',
173 check('alpha or alpha/1 or beta',
181 check('alpha/1 or beta',
189 check('alpha/1/i* or alpha/2/a or beta',
205 check('alpha/1/i* or alpha/2/a',