1
0
Fork 0

Added kagi-proofread tests, adjusted kagi-translate tests

This commit is contained in:
Bram Schoenmakers 2024-02-14 20:54:32 +01:00
parent 5415473f67
commit ed6df4ba19
Signed by: bram
GPG key ID: 0CCD19DFDC63258F

View file

@ -136,25 +136,39 @@ https://www.example.com"
(describe "kagi-translate" (describe "kagi-translate"
(before-each (before-each
(spy-on #'kagi-fastgpt-prompt)) (spy-on #'kagi-fastgpt-prompt))
(it "returns output on minimal input" (it "calls kagi-fastgpt-prompt non-interactively with target language in prompt"
(kagi-translate "foo" "English") (kagi-translate "hello" "toki pona")
(expect #'kagi-fastgpt-prompt :to-have-been-called-times 1) (expect #'kagi-fastgpt-prompt :to-have-been-called-times 1)
(let ((args (spy-calls-args-for #'kagi-fastgpt-prompt 0))) (let ((args (spy-calls-args-for #'kagi-fastgpt-prompt 0)))
;; has English in the prompt ;; not going to test the exact
(expect (nth 0 args) :to-match "English") ;; phrasing of the prompt, but at
;; least 'toki pona' has to
;; appear.
(expect (nth 0 args) :to-match "toki pona")
;; called non-interactively ;; called non-interactively
(expect (nth 2 args) :to-equal nil))) (expect (nth 2 args) :to-equal nil)))
(it "returns output with a source language" (it "calls kagi-fastgpt-prompt non-interactively with source and target language in prompt"
(kagi-translate "foo" "English" "Spanish") (kagi-translate "bonjour" "toki pona" "French")
(let ((args (spy-calls-args-for #'kagi-fastgpt-prompt 0))) (let ((args (spy-calls-args-for #'kagi-fastgpt-prompt 0)))
;; has English in the prompt ;; has 'toki pona' in the prompt
(expect (nth 0 args) :to-match "English") (expect (nth 0 args) :to-match "toki pona")
;; has Spanish in the prompt ;; and has French in the prompt
(expect (nth 0 args) :to-match "Spanish") (expect (nth 0 args) :to-match "French")
;; called non-interactively ;; called non-interactively
(expect (nth 2 args) :to-equal nil))) (expect (nth 2 args) :to-equal nil)))
(it "calls kagi-fastgpt-prompt with interactive flag when called interactively" (it "calls kagi-fastgpt-prompt with interactive flag when called interactively"
(kagi-translate "foo" "English" nil t) (kagi-translate "foo" "English" nil t)
(let ((args (spy-calls-args-for #'kagi-fastgpt-prompt 0)))
;; called interactively
(expect (nth 2 args) :to-equal t))))
(describe "kagi-proofread"
(before-each
(spy-on #'kagi-fastgpt-prompt))
(it "calls kagi-fastgpt-prompt"
(kagi-proofread "foo")
(expect #'kagi-fastgpt-prompt :to-have-been-called))
(it "calls kagi-fastgpt-prompt with interactive flag when called interactively"
(kagi-proofread "foo" t)
(let ((args (spy-calls-args-for #'kagi-fastgpt-prompt 0))) (let ((args (spy-calls-args-for #'kagi-fastgpt-prompt 0)))
;; called interactively ;; called interactively
(expect (nth 2 args) :to-equal t))))) (expect (nth 2 args) :to-equal t)))))