index.t 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # Copyright (C) 2019 Alex Schroeder <alex@gnu.org>
  2. #
  3. # This program is free software; you can redistribute it and/or modify it under
  4. # the terms of the GNU General Public License as published by the Free Software
  5. # Foundation; either version 3 of the License, or (at your option) any later
  6. # version.
  7. #
  8. # This program is distributed in the hope that it will be useful, but WITHOUT
  9. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  10. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License along with
  13. # this program. If not, see <http://www.gnu.org/licenses/>.
  14. require './t/test.pl';
  15. package OddMuse;
  16. use Test::More tests => 23;
  17. update_page('Test', 'Mu');
  18. test_page(get_page('action=index'),
  19. 'Include normal pages', 'Test');
  20. add_module('permanent-anchors.pl');
  21. # create a page with a permanent anchor
  22. update_page('Fix', '[::Moo]');
  23. # the default is to include permanent anchors
  24. $page = get_page('action=index');
  25. test_page($page,
  26. 'Include normal pages',
  27. 'Include permanent anchors');
  28. xpath_test($page, "//a[text()='Test']",
  29. "//a[text()='Fix']",
  30. "//a[text()='Moo']");
  31. # we can exclude permanent anchors
  32. $page = get_page('action=index permanentanchors=0');
  33. xpath_test($page, "//a[text()='Test']",
  34. "//a[text()='Fix']");
  35. negative_xpath_test($page, "//a[text()='Moo']");
  36. # or include them specifically
  37. $page = get_page('action=index permanentanchors=1');
  38. xpath_test($page, "//a[text()='Moo']");
  39. # and exclude normal pages
  40. $page = get_page('action=index pages=0 permanentanchors=1');
  41. xpath_test($page, "//a[text()='Moo']");
  42. negative_xpath_test($page,
  43. "//a[text()='Test']",
  44. "//a[text()='Fix']");
  45. add_module('near-links.pl');
  46. CreateDir($NearDir);
  47. WriteStringToFile("$NearDir/EmacsWiki",
  48. "Alex\n");
  49. update_page('InterMap', " EmacsWiki http://www.emacswiki.org/wiki/%s\n",
  50. 'required', 0, 1);
  51. update_page('NearMap', " EmacsWiki"
  52. . " http://www.emacswiki.org/wiki?action=index;raw=1"
  53. . " http://www.emacswiki.org/wiki?search=%s;raw=1;near=0\n",
  54. 'required', 0, 1);
  55. # the default is to not include near links
  56. $page = get_page('action=index');
  57. test_page($page,
  58. 'Include normal pages',
  59. 'Include permanent anchors',
  60. 'Include near pages');
  61. xpath_test($page, "//a[text()='Test']",
  62. "//a[text()='Fix']",
  63. "//a[text()='Moo']");
  64. negative_xpath_test($page, "//a[text()='Alex']");
  65. # we need to specifically include near links
  66. $page = get_page('action=index near=1');
  67. xpath_test($page, "//a[text()='Alex']");
  68. # or we can specifically exclude near links
  69. $page = get_page('action=index near=0');
  70. negative_xpath_test($page, "//a[text()='Alex']");