aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-02-26 22:19:05 -0300
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-02-26 22:19:05 -0300
commit7df79a35edcb79e7caca4a0d50fcec54d5f68fef (patch)
treecc2bcb61f4350dce6a5b5ecba12218f25645275f /test
parent83538b215f75256b86987b999504a2d87d0db307 (diff)
parentf4ba0e2a11581477e412c276080a049d19351361 (diff)
Merge branch 'master' into question-mode-line
Diffstat (limited to 'test')
-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)))))