123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- (require 'org-tempo)
- (unless (featurep 'org-tempo)
- (signal 'missing-test-dependency "org-tempo"))
- (ert-deftest test-org-tempo/completion ()
- "Test that blocks and keywords are expanded correctly by org-tempo."
-
- (should
- (equal (org-test-with-temp-text "<L<point>"
- (org-tempo-setup)
- (tempo-complete-tag)
- (buffer-string))
- "#+latex: "))
-
- (should
- (equal (org-test-with-temp-text "<l<point>"
- (org-tempo-setup)
- (call-interactively 'org-cycle)
- (buffer-string))
- "#+begin_export latex\n\n#+end_export"))
-
- (should
- (equal (org-test-with-temp-text "<L<point>"
- (org-tempo-setup)
- (tempo-complete-tag)
- (buffer-string))
- (org-test-with-temp-text "<L<point>"
- (org-tempo-setup)
- (org-cycle)
- (buffer-string))))
-
- (equal (org-test-with-temp-text "<k"
- (org-tempo-setup)
- (call-interactively 'org-cycle)
- (buffer-string))
- "<k"))
- (ert-deftest test-org-tempo/space-first-line ()
- "Test space on first line after expansion."
-
- (should (zerop
- (org-test-with-temp-text "<l<point>"
- (org-tempo-setup)
- (tempo-complete-tag)
- (goto-char (point-min))
- (end-of-line)
- (skip-chars-backward " "))))
-
-
- (should (cl-every (apply-partially 'eq 1)
- (mapcar (lambda (s)
- (org-test-with-temp-text (format "<%s<point>" s)
- (org-tempo-setup)
- (tempo-complete-tag)
- (goto-char (point-min))
- (end-of-line)
- (abs (skip-chars-backward " "))))
- '("s" "E" "L")))))
- (ert-deftest test-org-tempo/cursor-placement ()
- "Test the placement of the cursor after tempo expand"
-
- (should
- (eq (org-test-with-temp-text "<l<point>"
- (org-tempo-setup)
- (tempo-complete-tag)
- (point))
- (length "#\\+begin_export latex\n")))
-
- (should
- (eq (org-test-with-temp-text "<s<point>"
- (org-tempo-setup)
- (tempo-complete-tag)
- (point))
- (length "#\\+begin_src "))))
- (ert-deftest test-org-tempo/add-new-templates ()
- "Test that new structures and keywords are added correctly."
-
- (should
- (let ((org-structure-template-alist '(("n" . "new_block"))))
- (org-tempo-add-templates)
- (assoc "<l" org-tempo-tags)))
-
- (should
- (let ((org-tempo-keywords-alist '(("N" . "new_keyword"))))
- (org-tempo-add-templates)
- (assoc "<N" org-tempo-tags))))
- (provide 'test-org-tempo)
|