From bed5191a0137cb115656baf6ae3535b2a646d0b2 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Fri, 16 Jan 2015 12:56:02 -0200 Subject: Fix and improve tests --- test/test-printing.el | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/test-printing.el b/test/test-printing.el index 7384829..52fe5be 100644 --- a/test/test-printing.el +++ b/test/test-printing.el @@ -28,11 +28,18 @@ after being run through `sx-question--tag-format'." ;;; Tests (ert-deftest question-list-tag () - "Test `sx-question--tag-format'." + "Test `sx-tag--format'." (should - (string= - (sx-question--tag-format "tag") - "[tag]"))) + (string= (sx-tag--format "tag") "[tag]")) + (with-temp-buffer + (insert (sx-tag--format "tag")) + (should (get-char-property (point-min) 'button)) + (should + (eq (get-char-property (point-min) 'face) 'sx-tag)) + (should + (string= (get-char-property (point-min) 'sx-tag) "tag")) + (should + (string= (get-char-property (point-min) 'sx-button-copy) "tag")))) (ert-deftest question-list-display () (cl-letf (((symbol-function #'sx-request-make) -- cgit v1.2.3 From 76bfce36a4808e71aec27fdc2f7f8cef8462500f Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Fri, 23 Jan 2015 23:41:13 -0200 Subject: Add tests for sx-request-get-... --- test/test-api.el | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/test-api.el b/test/test-api.el index b7d5dbb..30590d7 100644 --- a/test/test-api.el +++ b/test/test-api.el @@ -14,3 +14,11 @@ (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 () + (should (sx-request-get-url "http://google.com")) + (should-error (sx-request-get-url "http://github.com/Bruce-Connor/does-not-exist")) + (should-error (sx-request-get-data "tags/emacs-does-not-exist")) + (let ((emacs-tags (length (sx-request-get-data 'tags/emacs)))) + (should (> emacs-tags 450)) + (should (not (cl-remove-if #'stringp emacs-tags))))) -- cgit v1.2.3 From a7a83411ccf68114847112bf27dced3d833cd524 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 24 Jan 2015 00:52:03 -0200 Subject: Test downloading image. --- test/test-api.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/test-api.el b/test/test-api.el index 30590d7..f7f54c1 100644 --- a/test/test-api.el +++ b/test/test-api.el @@ -21,4 +21,10 @@ (should-error (sx-request-get-data "tags/emacs-does-not-exist")) (let ((emacs-tags (length (sx-request-get-data 'tags/emacs)))) (should (> emacs-tags 450)) - (should (not (cl-remove-if #'stringp emacs-tags))))) + (should (not (cl-remove-if #'stringp emacs-tags)))) + (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 (min sx-question-mode-image-max-width + (window-body-width nil 'pixel))))) -- cgit v1.2.3 From 458231a11d0d54f8d7011addd9246661898cb2e0 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 24 Jan 2015 01:58:32 -0200 Subject: Fix and reorganize tests --- test/test-api.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/test-api.el b/test/test-api.el index f7f54c1..0715a2e 100644 --- a/test/test-api.el +++ b/test/test-api.el @@ -15,16 +15,18 @@ "Tests sx-method interface to `sx-request-all-items'" (should (< 250 (length (sx-method-call 'sites :get-all t))))) -(ert-deftest request-get () +(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")) - (should-error (sx-request-get-data "tags/emacs-does-not-exist")) - (let ((emacs-tags (length (sx-request-get-data 'tags/emacs)))) - (should (> emacs-tags 450)) - (should (not (cl-remove-if #'stringp emacs-tags)))) (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 (min sx-question-mode-image-max-width (window-body-width nil 'pixel))))) + +(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))))) -- cgit v1.2.3 From 6f83f1ef10f1316b489eba926aebecb51f37a6e7 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 26 Jan 2015 14:52:21 -0200 Subject: Fix test --- test/test-printing.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/test-printing.el b/test/test-printing.el index 52fe5be..a6815e2 100644 --- a/test/test-printing.el +++ b/test/test-printing.el @@ -13,7 +13,7 @@ (defmacro question-list-regex (title votes answers &rest tags) "Construct a matching regexp for TITLE, VOTES, and ANSWERS. Each element of TAGS is appended at the end of the expression -after being run through `sx-question--tag-format'." +after being run through `sx-tag--format'." `(rx line-start (+ whitespace) ,(number-to-string votes) (+ whitespace) ,(number-to-string answers) @@ -22,8 +22,7 @@ after being run through `sx-question--tag-format'." (+ (any whitespace digit)) (or "y" "d" "h" "m" "mo" "s") " ago" (+ whitespace) - (eval (mapconcat #'sx-question--tag-format - (list ,@tags) " ")))) + (eval (mapconcat #'sx-tag--format (list ,@tags) " ")))) ;;; Tests -- cgit v1.2.3 From 75c4a7d4e02e81c42a4914e2b798f60415a3b505 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 26 Jan 2015 15:28:19 -0200 Subject: Check image-type-available-p in the tests --- test/test-api.el | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/test-api.el b/test/test-api.el index 0715a2e..faf2e0a 100644 --- a/test/test-api.el +++ b/test/test-api.el @@ -18,12 +18,19 @@ (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")) - (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 (min sx-question-mode-image-max-width - (window-body-width nil 'pixel))))) + (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")) -- cgit v1.2.3 From dc4d2bee678428eb004d963bd21e08a347ef622e Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 12 Feb 2015 22:01:17 -0200 Subject: Fix test --- test/test-printing.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test-printing.el b/test/test-printing.el index 8016444..850edd8 100644 --- a/test/test-printing.el +++ b/test/test-printing.el @@ -167,8 +167,9 @@ after being run through `sx-tag--format'." "Check complicated questions are filled correctly." (should (equal - (sx-question-mode--fill-and-fontify - "Creating an account on a new site requires you to log into that site using *the same credentials you used on existing sites.* For instance, if you used the Stack Exchange login method, you'd... + (with-temp-buffer + (sx-question-mode--insert-markdown + "Creating an account on a new site requires you to log into that site using *the same credentials you used on existing sites.* For instance, if you used the Stack Exchange login method, you'd... 1. Click the \"Log in using Stack Exchange\" button: @@ -192,6 +193,7 @@ after being run through `sx-tag--format'." [1]: http://i.stack.imgur.com/ktFTs.png [2]: http://i.stack.imgur.com/5l2AY.png [3]: http://i.stack.imgur.com/22myl.png") + (buffer-string)) "Creating an account on a new site requires you to log into that site using *the same credentials you used on existing sites.* For instance, if you used the Stack Exchange login method, you'd... -- cgit v1.2.3