2 # Copyright (C) 2006, 2007 Alex Schroeder <alex@gnu.org>
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 use Test
::More tests
=> 30;
24 add_module
('usemod.pl');
26 InitVariables
(); # do this after loading usemod.pl!
28 # Note that we're not calling TocInit between tests, so we rely on
29 # them being run in order.
30 run_tests
('== make honey ==\n\nMoo.\n',
31 qq{<h2 id
="${TocAnchorPrefix}1">make honey
</h2><p>Moo.</p>},
32 '== make honey ==\nMoo.\n== make honey ==\nMoo.\n',
33 qq{<h2 id
="${TocAnchorPrefix}2">make honey
</h2><p>Moo. </p><h2 id
="${TocAnchorPrefix}3">make honey
</h2><p>Moo.</p>},
36 test_page
(update_page
('toc', "bla\n"
44 quotemeta('<div class="toc fnord mu">'));
46 # check whether the toc remains in the HTML cache
48 test_page
(get_page
('toc'),
49 quotemeta('<div class="toc fnord mu">'));
53 test_page
(get_page
('action=browse id=toc cache=0'),
54 quotemeta('<div class="toc fnord mu">'));
58 test_page
(get_page
('toc'),
59 quotemeta('<div class="toc fnord mu">'));
63 test_page
(update_page
('toc', "bla\n"
70 quotemeta(qq{<ol
><li
><a href
="#${TocAnchorPrefix}1">one
</a></li><li
><a href
="#${TocAnchorPrefix}2">two
</a></li><li
><a href
="#${TocAnchorPrefix}3">two
</a></li></ol
>}),
71 quotemeta(qq{<h2 id
="${TocAnchorPrefix}1">one
</h2
>}),
72 quotemeta(qq{<h2 id
="${TocAnchorPrefix}2">two
</h2
>}),
73 quotemeta(qq{bla
</p><div class="toc"><h2>$TocHeaderText</h2
><ol
><li
><a
}),
74 quotemeta(qq{two
</a></li></ol></div
><h2 id
="${TocAnchorPrefix}1">one
</h2
>}));
76 test_page
(update_page
('toc', "bla\n"
82 quotemeta(qq{<ol
><li
><a href
="#${TocAnchorPrefix}1">two
</a><ol><li><a href="#${TocAnchorPrefix}2">three</a></li></ol></li><li><a href="#${TocAnchorPrefix}3">two</a></li></ol>}),
83 quotemeta(qq{<h2 id
="${TocAnchorPrefix}1">two
</h2
>}),
84 quotemeta(qq{<h3 id
="${TocAnchorPrefix}2">three
</h3
>}));
86 test_page
(update_page
('toc', "bla\n"
94 quotemeta(qq{<ol
><li
><a href
="#${TocAnchorPrefix}1">two
</a><ol><li><a href="#${TocAnchorPrefix}2">three</a></li></ol></li><li><a href="#${TocAnchorPrefix}3">one</a></li></ol>}),
95 quotemeta(qq{<h2 id
="${TocAnchorPrefix}1">two
</h2
>}),
96 quotemeta(qq{<h2 id
="${TocAnchorPrefix}3">one
</h2
>}),
97 quotemeta(qq{bla
</p><div class="toc"><h2>$TocHeaderText</h2
><ol
><li
><a
}),
98 quotemeta('one</a></li></ol></div><p>murks'));
100 test_page
(update_page
('toc', "bla\n"
110 . "yadda <code>bla\n"
113 . "yadda <pre> has no effect! \n"
119 quotemeta(qq{<ol
><li
><a href
="#${TocAnchorPrefix}1">one
</a></li><li
><a href
="#${TocAnchorPrefix}2">two
</a></li><li
><a href
="#${TocAnchorPrefix}3">three
</a></li><li
><a href
="#${TocAnchorPrefix}4">one
</a></li></ol
>}),
120 quotemeta(qq{<h2 id
="${TocAnchorPrefix}1">one
</h2
>}),
121 quotemeta(qq{<h2 id
="${TocAnchorPrefix}2">two
</h2
>}),
122 quotemeta(qq{<h2 id
="${TocAnchorPrefix}3">three
</h2
>}),
123 quotemeta(qq{<h2 id
="${TocAnchorPrefix}4">one
</h2
>}));
125 add_module
('markup.pl');
127 test_page
(update_page
('toc', "bla\n"
138 quotemeta(qq{<ol
><li
><a href
="#${TocAnchorPrefix}1">one
</a></li><li
><a href
="#${TocAnchorPrefix}2">four
</a></li></ol
>}),
139 quotemeta(qq{<h2 id
="${TocAnchorPrefix}1">one
</h2
>}),
140 quotemeta(qq{<h2 id
="${TocAnchorPrefix}2">four
</h2
>}));
142 test_page
(update_page
('toc', "bla\n"
144 . "blarg ##<code>## and <code>##</code>\n"
146 . "blarg ##</code>##\n"),
147 quotemeta(qq{<ol
><li
><a href
="#${TocAnchorPrefix}1">one
</a></li><li
><a href
="#${TocAnchorPrefix}2">two
</a></li></ol
>}),
148 quotemeta(qq{<h2 id
="${TocAnchorPrefix}1">one
</h2
>}),
149 quotemeta(qq{<h2 id
="${TocAnchorPrefix}2">two
</h2
>}));