test-org-pcomplete.el 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. ;;; test-org-pcomplete.el --- test pcomplete integration
  2. ;; Copyright (C) 2015-2016 Alexey Lebedeff
  3. ;; Authors: Alexey Lebedeff
  4. ;; This file is not part of GNU Emacs.
  5. ;; This program is free software; you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (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.
  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. ;;; Comments:
  16. ;;; Code:
  17. (ert-deftest test-org-pcomplete/clocktable ()
  18. "Test completion of clock table parameters."
  19. (should
  20. (equal "#+begin: clocktable :scope"
  21. (org-test-with-temp-text "#+begin: clocktable :sco<point>"
  22. (pcomplete)
  23. (buffer-string)))))
  24. (ert-deftest test-org-pcomplete/drawer ()
  25. "Test drawer completion."
  26. (should
  27. (equal "* Foo\n:PROPERTIES:"
  28. (org-test-with-temp-text "* Foo\n:<point>"
  29. (pcomplete)
  30. (buffer-string))))
  31. (should
  32. (equal ":DRAWER:\nContents\n:END:\n* Foo\n:DRAWER:"
  33. (org-test-with-temp-text ":DRAWER:\nContents\n:END:\n* Foo\n:D<point>"
  34. (pcomplete)
  35. (buffer-string)))))
  36. (ert-deftest test-org-pcomplete/entity ()
  37. "Test entity completion."
  38. (should
  39. (equal "\\alpha"
  40. (org-test-with-temp-text "\\alp<point>"
  41. (pcomplete)
  42. (buffer-string))))
  43. (should
  44. (equal "\\frac12"
  45. (org-test-with-temp-text "\\frac1<point>"
  46. (pcomplete)
  47. (buffer-string)))))
  48. (ert-deftest test-org-pcomplete/keyword ()
  49. "Test keyword and block completion."
  50. (should
  51. (string-prefix-p
  52. "#+startup: "
  53. (org-test-with-temp-text "#+start<point>"
  54. (pcomplete)
  55. (buffer-string))
  56. t))
  57. (should
  58. (string-prefix-p
  59. "#+begin_center"
  60. (org-test-with-temp-text "#+begin_ce<point>"
  61. (pcomplete)
  62. (buffer-string))
  63. t)))
  64. (ert-deftest test-org-pcomplete/link ()
  65. "Test link completion"
  66. (should
  67. (equal "[[org:"
  68. (org-test-with-temp-text "[[o<point>"
  69. (let ((org-link-abbrev-alist '(("org" . "https://orgmode.org/"))))
  70. (pcomplete))
  71. (buffer-string))))
  72. (should-not
  73. (equal "[org:"
  74. (org-test-with-temp-text "[[o<point>"
  75. (let ((org-link-abbrev-alist '(("org" . "https://orgmode.org/"))))
  76. (pcomplete))
  77. (buffer-string)))))
  78. (ert-deftest test-org-pcomplete/prop ()
  79. "Test property completion."
  80. (should
  81. (equal
  82. "
  83. * a
  84. :PROPERTIES:
  85. :pname:\s
  86. :END:
  87. * b
  88. :PROPERTIES:
  89. :pname: pvalue
  90. :END:
  91. "
  92. (org-test-with-temp-text "
  93. * a
  94. :PROPERTIES:
  95. :pna<point>
  96. :END:
  97. * b
  98. :PROPERTIES:
  99. :pname: pvalue
  100. :END:
  101. "
  102. (pcomplete)
  103. (buffer-string)))))
  104. (ert-deftest test-org-pcomplete/search-heading ()
  105. "Test search heading completion."
  106. (should
  107. (equal "* Foo\n[[*Foo"
  108. (org-test-with-temp-text "* Foo\n[[*<point>"
  109. (pcomplete)
  110. (buffer-string)))))
  111. (ert-deftest test-org-pcomplete/todo ()
  112. "Test TODO completion."
  113. (should
  114. (equal "* TODO"
  115. (org-test-with-temp-text "* T<point>"
  116. (pcomplete)
  117. (buffer-string)))))
  118. (provide 'test-org-pcomplete)
  119. ;;; test-org-pcomplete.el ends here