aboutsummaryrefslogtreecommitdiff
path: root/test/mastodon-media-tests.el
diff options
context:
space:
mode:
authormousebot <mousebot@riseup.net>2021-11-09 11:35:57 +0100
committermousebot <mousebot@riseup.net>2021-11-09 11:35:57 +0100
commit3014e10ec268250a130ac490b5f32b3d263ad21b (patch)
tree56fe46ea7f274d38d89b5c2c94fece4951769e08 /test/mastodon-media-tests.el
parent4d00c5f3d91aba2dea867d6b8fa7cbec1d6d9ff2 (diff)
update mastodon-media:get-media-link-rendering{-gif}
to handle adding property "type" to media, and to display in help-echo if not an image.
Diffstat (limited to 'test/mastodon-media-tests.el')
-rw-r--r--test/mastodon-media-tests.el29
1 files changed, 28 insertions, 1 deletions
diff --git a/test/mastodon-media-tests.el b/test/mastodon-media-tests.el
index 7124672..252c819 100644
--- a/test/mastodon-media-tests.el
+++ b/test/mastodon-media-tests.el
@@ -24,7 +24,8 @@
(let* ((mastodon-media--preview-max-height 123)
(result
(mastodon-media--get-media-link-rendering "http://example.org/img.png"
- "http://example.org/remote/img.png"))
+ "http://example.org/remote/img.png"
+ "image"))
(result-no-properties (substring-no-properties result))
(properties (text-properties-at 0 result)))
(should (string= "[img] " result-no-properties))
@@ -36,7 +37,33 @@
(should (eq 'image (plist-get properties 'mastodon-tab-stop)))
(should (string= "http://example.org/remote/img.png" (plist-get properties 'image-url)))
(should (eq mastodon-tl--shr-image-map-replacement (plist-get properties 'keymap)))
+ (should (string= "image" (plist-get properties 'mastodon-media-type)))
(should (string= "RET/i: load full image (prefix: copy URL), +/-: zoom, r: rotate, o: save preview"
+ (plist-get properties 'help-echo))))))
+
+(ert-deftest mastodon-media:get-media-link-rendering-gif ()
+ "Should return text with all expected properties."
+ (with-mock
+ (mock (create-image * nil t) => :mock-image)
+
+ (let* ((mastodon-media--preview-max-height 123)
+ (result
+ (mastodon-media--get-media-link-rendering "http://example.org/img.png"
+ "http://example.org/remote/img.png"
+ "gifv"))
+ (result-no-properties (substring-no-properties result))
+ (properties (text-properties-at 0 result)))
+ (should (string= "[img] " result-no-properties))
+ (should (string= "http://example.org/img.png" (plist-get properties 'media-url)))
+ (should (eq 'needs-loading (plist-get properties 'media-state)))
+ (should (eq 'media-link (plist-get properties 'media-type)))
+ (should (eq :mock-image (plist-get properties 'display)))
+ (should (eq 'highlight (plist-get properties 'mouse-face)))
+ (should (eq 'image (plist-get properties 'mastodon-tab-stop)))
+ (should (string= "http://example.org/remote/img.png" (plist-get properties 'image-url)))
+ (should (eq mastodon-tl--shr-image-map-replacement (plist-get properties 'keymap)))
+ (should (string= "gifv" (plist-get properties 'mastodon-media-type)))
+ (should (string= "RET/i: load full image (prefix: copy URL), +/-: zoom, r: rotate, o: save preview\ntype: gifv"
(plist-get properties 'help-echo))))))
(ert-deftest mastodon-media:load-image-from-url:avatar-with-imagemagic ()