aboutsummaryrefslogtreecommitdiff
path: root/test/test-api.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-02-26 22:24:58 -0300
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-02-26 22:24:58 -0300
commitee4e74f25fdb97faf4cb92952072a42b7b507e2a (patch)
treeea083b78a425cde9ed8184ba269894c15f10f938 /test/test-api.el
parentcd629005cc68f0eeefc42a92ea1e75658791439f (diff)
parentf4ba0e2a11581477e412c276080a049d19351361 (diff)
Merge branch 'master' into generate-header-line-from-keymap
Diffstat (limited to 'test/test-api.el')
-rw-r--r--test/test-api.el23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/test-api.el b/test/test-api.el
index b7d5dbb..faf2e0a 100644
--- a/test/test-api.el
+++ b/test/test-api.el
@@ -14,3 +14,26 @@
(ert-deftest test-method-get-all ()
"Tests sx-method interface to `sx-request-all-items'"
(should (< 250 (length (sx-method-call 'sites :get-all t)))))
+
+(ert-deftest request-get-url ()
+ (should (sx-request-get-url "http://google.com"))
+ (should-error (sx-request-get-url "http://github.com/Bruce-Connor/does-not-exist"))
+ (when sx-question-mode-use-images
+ (should
+ ;; If image is not recognized, this returns nil.
+ (create-image (sx-request-get-url "https://raw.githubusercontent.com/vermiculus/sx.el/master/list-and-question.png")
+ 'imagemagick t
+ :width sx-question-mode-image-max-width)))
+ ;; In case imagemacgick is not available, let's try png so we at
+ ;; least test the function.
+ (when (image-type-available-p 'png)
+ (should
+ (create-image (sx-request-get-url "https://raw.githubusercontent.com/vermiculus/sx.el/master/list-and-question.png")
+ 'png t
+ :width sx-question-mode-image-max-width))))
+
+(ert-deftest request-get-data ()
+ (should-error (sx-request-get-data "tags/emacs-does-not-exist"))
+ (let ((emacs-tags (sx-request-get-data 'tags/emacs)))
+ (should (> (length emacs-tags) 450))
+ (should (not (cl-remove-if #'stringp emacs-tags)))))