Add tests for kagi-summarize-url
This commit is contained in:
parent
02be283f3a
commit
602b7dffb4
53
kagi-test.el
53
kagi-test.el
|
@ -370,12 +370,57 @@ https://www.example.com"
|
|||
(spy-on #'buffer-substring-no-properties))
|
||||
(it "passes arguments to kagi-summary"
|
||||
(call-interactively #'kagi-summarize-region)
|
||||
(expect #'kagi--display-summary :to-have-been-called)
|
||||
(kagi-test--expect-arg #'kagi--display-summary 1 :to-equal "buffer-name (summary)")
|
||||
(kagi-test--expect-arg #'kagi-summarize :to-have-been-called)
|
||||
(expect #'kagi-summarize :to-have-been-called)
|
||||
(kagi-test--expect-arg #'kagi-summarize 1 :to-equal 'lang)
|
||||
(kagi-test--expect-arg #'kagi-summarize 2 :to-equal 'bram)
|
||||
(kagi-test--expect-arg #'kagi-summarize 3 :to-equal 'random)))
|
||||
(describe "kagi-summarize-url")))
|
||||
(kagi-test--expect-arg #'kagi-summarize 3 :to-equal 'random))
|
||||
(it "opens a buffer with the summary"
|
||||
(call-interactively #'kagi-summarize-region)
|
||||
(expect #'kagi--display-summary :to-have-been-called)
|
||||
(kagi-test--expect-arg #'kagi--display-summary 0 :to-equal dummy-output)))
|
||||
(describe "kagi-summarize-url"
|
||||
(before-each
|
||||
(spy-on #'kagi-summarize :and-return-value dummy-output)
|
||||
(spy-on #'read-string :and-return-value "https://www.example.com")
|
||||
(spy-on #'kagi--get-summarizer-parameters :and-return-value '(nil lang bram random)))
|
||||
(it "passes arguments to kagi-summary"
|
||||
(call-interactively #'kagi-summarize-url)
|
||||
(kagi-test--expect-arg #'kagi-summarize 1 :to-equal 'lang)
|
||||
(kagi-test--expect-arg #'kagi-summarize 2 :to-equal 'bram)
|
||||
(kagi-test--expect-arg #'kagi-summarize 3 :to-equal 'random))
|
||||
(it "opens a buffer with the summary"
|
||||
(call-interactively #'kagi-summarize-url)
|
||||
(expect #'kagi--display-summary :to-have-been-called)
|
||||
(kagi-test--expect-arg #'kagi--display-summary 0 :to-equal dummy-output))
|
||||
(it "opens a buffer with the domain name for an HTTPS URL"
|
||||
(call-interactively #'kagi-summarize-url)
|
||||
(expect #'kagi--display-summary :to-have-been-called)
|
||||
(kagi-test--expect-arg #'kagi--display-summary 1 :to-equal "example.com (summary)"))
|
||||
(it "opens a buffer with the domain name for an HTTP URL"
|
||||
(spy-on #'read-string :and-return-value "http://www.example.com")
|
||||
(call-interactively #'kagi-summarize-url)
|
||||
(expect #'kagi--display-summary :to-have-been-called)
|
||||
(kagi-test--expect-arg #'kagi--display-summary 1 :to-equal "example.com (summary)"))
|
||||
(it "opens a buffer with the domain name for an HTTPS URL ending with /"
|
||||
(spy-on #'read-string :and-return-value "https://www.example.com/")
|
||||
(call-interactively #'kagi-summarize-url)
|
||||
(expect #'kagi--display-summary :to-have-been-called)
|
||||
(kagi-test--expect-arg #'kagi--display-summary 1 :to-equal "example.com (summary)"))
|
||||
(it "opens a buffer with the domain name for an HTTPS URL ending with path"
|
||||
(spy-on #'read-string :and-return-value "https://www.example.com/aaa/")
|
||||
(call-interactively #'kagi-summarize-url)
|
||||
(expect #'kagi--display-summary :to-have-been-called)
|
||||
(kagi-test--expect-arg #'kagi--display-summary 1 :to-equal "example.com (summary)"))
|
||||
(it "opens a buffer with the domain name for an HTTPS URL with subdomain"
|
||||
(spy-on #'read-string :and-return-value "https://abc.example.com/")
|
||||
(call-interactively #'kagi-summarize-url)
|
||||
(expect #'kagi--display-summary :to-have-been-called)
|
||||
(kagi-test--expect-arg #'kagi--display-summary 1 :to-equal "abc.example.com (summary)"))
|
||||
(xit "inserts the summary when requested non-interactively"
|
||||
(kagi-summarize-url "https://www.example.com" t)
|
||||
(expect #'kagi--display-summary :not :to-have-been-called)
|
||||
(expect #'kagi--insert-summary :to-have-been-called)
|
||||
(kagi-test--expect-arg #'kagi--insert-summary 0 :to-equal dummy-output)))))
|
||||
|
||||
;;; kagi-test.el ends here
|
||||
|
|
Loading…
Reference in a new issue