test-org-pcomplete.el 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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/prop ()
  18. "Test property completion."
  19. ;; Drawer where we are currently completing property name is
  20. ;; malformed in any case, it'll become valid only after successful
  21. ;; completion. We expect that this completion process will finish
  22. ;; successfully, and there will be no interactive drawer repair
  23. ;; attempts.
  24. (should
  25. (equal
  26. "* a\n:PROPERTIES:\n:pname: \n:END:\n* b\n:PROPERTIES:\n:pname: pvalue\n:END:\n"
  27. (org-test-with-temp-text "* a\n:PROPERTIES:\n:pna<point>\n:END:\n* b\n:PROPERTIES:\n:pname: pvalue\n:END:\n"
  28. (cl-letf (((symbol-function 'y-or-n-p)
  29. (lambda (_) (error "Should not be called"))))
  30. (pcomplete))
  31. (buffer-string)))))
  32. (ert-deftest test-org-pcomplete/keyword ()
  33. "Test keyword and block completion."
  34. (should
  35. (string-prefix-p
  36. "#+startup: "
  37. (org-test-with-temp-text "#+start<point>"
  38. (pcomplete)
  39. (buffer-string))
  40. t))
  41. (should
  42. (string-prefix-p
  43. "#+begin_center"
  44. (org-test-with-temp-text "#+begin_ce<point>"
  45. (pcomplete)
  46. (buffer-string))
  47. t)))
  48. (provide 'test-org-pcomplete)
  49. ;;; test-org-pcomplete.el ends here