aboutsummaryrefslogtreecommitdiff
path: root/test/mastodon-media-tests.el
diff options
context:
space:
mode:
authorHolger Dürer <me@hdurer.net>2021-11-01 15:53:37 +0100
committerHolger Dürer <me@hdurer.net>2021-11-01 15:53:37 +0100
commite7c7da386c812f9452b072567e822077180f3dc5 (patch)
treecfd28454b3c54404381620a1e77e722b6d5e9740 /test/mastodon-media-tests.el
parentd7593a06912b7946d2fb318093ec7e27c64b3be7 (diff)
Fix tests.
These needed a bit of tender love and care to get back into passing state. - Move the auth tests to the `test` directory. No idea what it was doing in `lisp`. - Image tests are mostly broken because with later Emacsen we no longer need the `imagemagic` option on create-image. - Some method signatures have changed and mocking calls needed to follow suit.
Diffstat (limited to 'test/mastodon-media-tests.el')
-rw-r--r--test/mastodon-media-tests.el34
1 files changed, 23 insertions, 11 deletions
diff --git a/test/mastodon-media-tests.el b/test/mastodon-media-tests.el
index a586be9..20993f9 100644
--- a/test/mastodon-media-tests.el
+++ b/test/mastodon-media-tests.el
@@ -4,7 +4,7 @@
"Should return text with all expected properties."
(with-mock
(mock (image-type-available-p 'imagemagick) => t)
- (mock (create-image * 'imagemagick t :height 123) => :mock-image)
+ (mock (create-image * (when (version< emacs-version "27.1") 'imagemagick) t :height 123) => :mock-image)
(let* ((mastodon-media--avatar-height 123)
(result (mastodon-media--get-avatar-rendering "http://example.org/img.png"))
@@ -37,12 +37,15 @@
(mastodon-media--avatar-height 123))
(with-mock
(mock (image-type-available-p 'imagemagick) => t)
- (mock (create-image * 'imagemagick t :height 123) => '(image foo))
+ (mock (create-image
+ *
+ (when (version< emacs-version "27.1") 'imagemagick)
+ t :height 123) => '(image foo))
(mock (copy-marker 7) => :my-marker )
(mock (url-retrieve
url
#'mastodon-media--process-image-response
- '(:my-marker (:height 123) 1))
+ `(:my-marker (:height 123) 1 ,url))
=> :called-as-expected)
(with-temp-buffer
@@ -62,7 +65,7 @@
(mock (url-retrieve
url
#'mastodon-media--process-image-response
- '(:my-marker () 1))
+ `(:my-marker () 1 ,url))
=> :called-as-expected)
(with-temp-buffer
@@ -82,7 +85,7 @@
(mock (url-retrieve
"http://example.org/image.png"
#'mastodon-media--process-image-response
- '(:my-marker (:max-height 321) 5))
+ '(:my-marker (:max-height 321) 5 "http://example.org/image.png"))
=> :called-as-expected)
(with-temp-buffer
(insert (concat "Start:"
@@ -101,7 +104,7 @@
(mock (url-retrieve
"http://example.org/image.png"
#'mastodon-media--process-image-response
- '(:my-marker () 5))
+ '(:my-marker () 5 "http://example.org/image.png"))
=> :called-as-expected)
(with-temp-buffer
@@ -117,7 +120,10 @@
(mastodon-media--avatar-height 123))
(with-mock
(mock (image-type-available-p 'imagemagick) => t)
- (mock (create-image * 'imagemagick t :height 123) => '(image foo))
+ (mock (create-image
+ *
+ (when (version< emacs-version "27.1") 'imagemagick)
+ t :height 123) => '(image foo))
(stub url-retrieve => (error "url-retrieve failed"))
(with-temp-buffer
@@ -139,9 +145,11 @@
(insert "start:")
(setq used-marker (copy-marker (point))
saved-marker (copy-marker (point)))
- ;; Mock needed for the preliminary image created in mastodon-media--get-avatar-rendering
+ ;; Mock needed for the preliminary image created in
+ ;; mastodon-media--get-avatar-rendering
(stub create-image => :fake-image)
- (insert (mastodon-media--get-avatar-rendering "http://example.org/image.png")
+ (insert (mastodon-media--get-avatar-rendering
+ "http://example.org/image.png.")
":end")
(with-temp-buffer
(insert "some irrelevant\n"
@@ -150,9 +158,13 @@
"fake\nimage\ndata")
(goto-char (point-min))
- (mock (create-image "fake\nimage\ndata" 'imagemagick t ':image :option) => :fake-image)
+ (mock (create-image
+ "fake\nimage\ndata"
+ (when (version< emacs-version "27.1") 'imagemagick)
+ t ':image :option) => :fake-image)
- (mastodon-media--process-image-response () used-marker '(:image :option) 1)
+ (mastodon-media--process-image-response
+ () used-marker '(:image :option) 1 "http://example.org/image.png")
;; the used marker has been unset:
(should (null (marker-position used-marker)))