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->content_list) {
76 my @kids = $li->content_list;
80 my $expectation = shift @$expected;
82 is($kids[0]->tag, 'a');
85 if ($expectation->{parent}) {
86 is($a->attr('class'), 'mapparent');
89 is($a->attr('class'), 'mapitem');
92 is_deeply([$a->content_list], [$expectation->{name}]);
94 if (@{$expectation->{kids}}) {
95 is($kids[1]->tag, 'ul');
98 check_nodes($kids[1], $expectation->{kids});
101 is_deeply([@kids], [$a]);
107 my $pagespec = shift;
108 my $expected = shift;
110 my $html = IkiWiki::Plugin::map::preprocess(pages => $pagespec,
113 my $tree = HTML::TreeBuilder->new;
114 $tree->implicit_tags(0);
115 $tree->unbroken_text(1);
116 $tree->strict_end(1);
117 $tree->strict_names(1);
118 $tree->strict_comment(1);
119 $tree->empty_element_tags(1);
120 $tree->parse_content($html);
121 my $fragment = $tree->disembowel;
122 print $fragment->dump;
124 is($fragment->tag, 'div');
125 is($fragment->attr('class'), 'map');
127 check_nodes(($fragment->content_list)[0], $expected);
133 check('alpha', [node('alpha', [])]);
150 check('alpha or alpha/*',
167 check('alpha or alpha/1 or beta',