headers.t 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # Copyright (C) 2006, 2007 Alex Schroeder <alex@gnu.org>
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. require 't/test.pl';
  16. package OddMuse;
  17. use Test::More tests => 13;
  18. # without portrait-support
  19. # nothing
  20. update_page('headers', "== no header ==\n\ntext\n");
  21. test_page(get_page('headers'), '== no header ==');
  22. # usemod only
  23. add_module('usemod.pl');
  24. update_page('headers', "== is header ==\n\ntext\n");
  25. test_page(get_page('headers'), '<h2>is header</h2>');
  26. # toc + usemod only
  27. add_module('toc.pl');
  28. test_page(update_page('headers', "== one ==\ntext\n== two ==\ntext\n== three ==\ntext\n"),
  29. '<li><a href="#Heading1">one</a></li>',
  30. '<li><a href="#Heading2">two</a></li>',
  31. '<h2 id="Heading1">one</h2>',
  32. '<h2 id="Heading2">two</h2>', );
  33. remove_module('usemod.pl');
  34. remove_rule(\&UsemodRule);
  35. # toc + headers
  36. add_module('headers.pl');
  37. test_page(update_page('headers', "one\n===\ntext\ntwo\n---\ntext\nthree\n====\ntext\n"),
  38. '<li><a href="#Heading1">one</a>',
  39. '<ol><li><a href="#Heading2">two</a></li></ol>',
  40. '<li><a href="#Heading3">three</a></li>',
  41. '<h2 id="Heading1">one</h2>',
  42. '<h3 id="Heading2">two</h3>',
  43. '<h2 id="Heading3">three</h2>', );
  44. remove_module('toc.pl');
  45. remove_rule(\&TocRule);
  46. # headers only
  47. test_page(update_page('headers', "is header\n=========\n\ntext\n"),
  48. '<h2>is header</h2>');
  49. # update_page('headers', "is header\n=========\n\ntext\n");
  50. # test_page(get_page('headers'), '<h2>is header</h2>');