test-org-tempo.el 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ;;; test-org-tempo.el --- Tests for test-org-tempo.el -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2017 Rasmus Pank Roulund
  3. ;; Author: Rasmus Pank Roulund <emacs at pank dot eu>
  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. ;;; Code:
  16. (require 'org-tempo)
  17. (unless (featurep 'org-temp)
  18. (signal 'missing-test-dependency "org-tempo"))
  19. (ert-deftest test-org-tempo/completion ()
  20. "Test that blocks and keywords are expanded correctly by org-tempo."
  21. ;; Tempo completion should recognize snippet keywords and expand with tab
  22. (should
  23. (equal (org-test-with-temp-text "<L<point>"
  24. (org-tempo-setup)
  25. (tempo-complete-tag)
  26. (buffer-string))
  27. "#+latex: "))
  28. ;; Tempo completion should recognize snippet Blocks
  29. (should
  30. (equal (org-test-with-temp-text "<l<point>"
  31. (org-tempo-setup)
  32. (call-interactively 'org-cycle)
  33. (buffer-string))
  34. "#+begin_export latex \n\n#+end_export"))
  35. ;; Tab should work for expansion.
  36. (should
  37. (equal (org-test-with-temp-text "<L<point>"
  38. (org-tempo-setup)
  39. (tempo-complete-tag)
  40. (buffer-string))
  41. (org-test-with-temp-text "<L<point>"
  42. (org-tempo-setup)
  43. (org-cycle)
  44. (buffer-string))))
  45. ;; Tempo should not expand unknown snippets
  46. (equal (org-test-with-temp-text "<k"
  47. (org-tempo-setup)
  48. (call-interactively 'org-cycle)
  49. (buffer-string))
  50. "<k"))
  51. (ert-deftest test-org-tempo/add-new-templates ()
  52. "Test that new structures and keywords are added correctly."
  53. ;; Check that deleted keys are not kept
  54. (should
  55. (let ((org-structure-template-alist '((?n . "new_block"))))
  56. (org-tempo-add-templates)
  57. (assoc "<n" org-tempo-tags)))
  58. (should
  59. (let ((org-tempo-keywords-alist '((?N . "new_keyword"))))
  60. (org-tempo-add-templates)
  61. (assoc "<N" org-tempo-tags))))
  62. (provide 'test-org-tempo)
  63. ;;; test-org-tempo.el end here