mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-06 13:22:12 +00:00
Test get-current-text helpers for Find Similar feature in khoj.el
This commit is contained in:
@@ -150,6 +150,102 @@ Rule everything\n\
|
|||||||
\n\
|
\n\
|
||||||
"))))
|
"))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;; -------------------------------------
|
||||||
|
;; Test Helpers for Find Similar Feature
|
||||||
|
;; -------------------------------------
|
||||||
|
|
||||||
|
(ert-deftest khoj-tests--get-current-outline-entry-text ()
|
||||||
|
"Test get current outline-mode entry text'."
|
||||||
|
(with-temp-buffer
|
||||||
|
(insert "\
|
||||||
|
* Become God\n\
|
||||||
|
** Upgrade\n\
|
||||||
|
\n\
|
||||||
|
Penance to Immortality\n\
|
||||||
|
** Act\n\
|
||||||
|
\n\
|
||||||
|
Rule everything\\n")
|
||||||
|
(goto-char (point-min))
|
||||||
|
|
||||||
|
;; Test getting current entry text from cursor at start of outline heading
|
||||||
|
(outline-next-visible-heading 1)
|
||||||
|
(should
|
||||||
|
(equal
|
||||||
|
(khoj--get-current-outline-entry-text)
|
||||||
|
"\
|
||||||
|
** Upgrade\n\
|
||||||
|
\n\
|
||||||
|
Penance to Immortality"))
|
||||||
|
|
||||||
|
;; Test getting current entry text from cursor within outline entry
|
||||||
|
(forward-line)
|
||||||
|
(should
|
||||||
|
(equal
|
||||||
|
(khoj--get-current-outline-entry-text)
|
||||||
|
"\
|
||||||
|
** Upgrade\n\
|
||||||
|
\n\
|
||||||
|
Penance to Immortality"))
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
|
(ert-deftest khoj-tests--get-current-paragraph-text ()
|
||||||
|
"Test get current paragraph text'."
|
||||||
|
(with-temp-buffer
|
||||||
|
(insert "\
|
||||||
|
* Become God\n\
|
||||||
|
** Upgrade\n\
|
||||||
|
\n\
|
||||||
|
Penance to Immortality\n\
|
||||||
|
** Act\n\
|
||||||
|
\n\
|
||||||
|
Rule everything\n")
|
||||||
|
;; Test getting current paragraph text from cursor at start of buffer
|
||||||
|
(goto-char (point-min))
|
||||||
|
(should
|
||||||
|
(equal
|
||||||
|
(khoj--get-current-paragraph-text)
|
||||||
|
"* Become God\n\
|
||||||
|
** Upgrade"))
|
||||||
|
|
||||||
|
;; Test getting current paragraph text from cursor within paragraph
|
||||||
|
(goto-char (point-min))
|
||||||
|
(forward-line 1)
|
||||||
|
(should
|
||||||
|
(equal
|
||||||
|
(khoj--get-current-paragraph-text)
|
||||||
|
"* Become God\n\
|
||||||
|
** Upgrade"))
|
||||||
|
|
||||||
|
;; Test getting current paragraph text from cursor at paragraph end
|
||||||
|
(goto-char (point-min))
|
||||||
|
(forward-line 2)
|
||||||
|
(should
|
||||||
|
(equal
|
||||||
|
(khoj--get-current-paragraph-text)
|
||||||
|
"* Become God\n\
|
||||||
|
** Upgrade"))
|
||||||
|
|
||||||
|
;; Test getting current paragraph text from cursor at start of middle paragraph
|
||||||
|
(goto-char (point-min))
|
||||||
|
(forward-line 3)
|
||||||
|
(should
|
||||||
|
(equal
|
||||||
|
(khoj--get-current-paragraph-text)
|
||||||
|
"Penance to Immortality\n\
|
||||||
|
** Act"))
|
||||||
|
|
||||||
|
;; Test getting current paragraph text from cursor at end of buffer
|
||||||
|
(goto-char (point-max))
|
||||||
|
(should
|
||||||
|
(equal
|
||||||
|
(khoj--get-current-paragraph-text)
|
||||||
|
"Rule everything"))
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
(provide 'khoj-tests)
|
(provide 'khoj-tests)
|
||||||
|
|
||||||
;;; khoj-tests.el ends here
|
;;; khoj-tests.el ends here
|
||||||
|
|||||||
Reference in New Issue
Block a user