aboutsummaryrefslogtreecommitdiff
path: root/test/mastodon-profile-tests.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus@riseup.net>2024-09-20 20:37:35 +0200
committermarty hiatt <martianhiatus@riseup.net>2024-09-20 20:37:35 +0200
commit6803d680c6415e4cc6dca66e597776dae0394170 (patch)
tree7795f10a3b5337d4b2169d6eab3adec654fc7cc0 /test/mastodon-profile-tests.el
parent3443b49c55f65ae8e0b07e93e1e0299ce1bf8ed6 (diff)
parent657bd3664749f66d9da0a8a5336b51c592670ecf (diff)
Merge branch 'develop'
Diffstat (limited to 'test/mastodon-profile-tests.el')
-rw-r--r--test/mastodon-profile-tests.el83
1 files changed, 45 insertions, 38 deletions
diff --git a/test/mastodon-profile-tests.el b/test/mastodon-profile-tests.el
index d187e2d..289e8d9 100644
--- a/test/mastodon-profile-tests.el
+++ b/test/mastodon-profile-tests.el
@@ -23,12 +23,12 @@
(statuses_count . 70741)
(last_status_at . "2021-11-14")
(emojis . [])
- (fields . [((name . "Patreon")
+ (fields . (((name . "Patreon")
(value . "<a href=\"https://www.patreon.com/mastodon\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://www.</span><span class=\"\">patreon.com/mastodon</span><span class=\"invisible\"></span></a>")
(verified_at))
((name . "Homepage")
(value . "<a href=\"https://zeonfederated.com\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"\">zeonfederated.com</span><span class=\"invisible\"></span></a>")
- (verified_at . "2019-07-15T18:29:57.191+00:00"))])))
+ (verified_at . "2019-07-15T18:29:57.191+00:00"))))))
(defconst ccc-profile-json
'((id . "369027")
@@ -105,10 +105,10 @@
(website))
(account ,@gargron-profile-json)
(media_attachments . [])
- (mentions . [((id . "369027")
+ (mentions . (((id . "369027")
(username . "CCC")
(url . "https://social.bau-ha.us/@CCC")
- (acct . "CCC@social.bau-ha.us"))])
+ (acct . "CCC@social.bau-ha.us"))))
(tags . [])
(emojis . [])
(card)
@@ -170,11 +170,10 @@ When formatting Gargon's state we want to see
The search will happen as if called without the \"@\"."
(with-mock
-
(mock (mastodon-http--get-json
- "https://instance.url/api/v1/accounts/search"
- '(("q" . "gargron"))))
-
+ "https://instance.url/api/v2/search"
+ '(("q" . "gargron")
+ ("type" . "accounts"))))
(let ((mastodon-instance-url "https://instance.url"))
;; We don't check anything from the return value. We only care
;; that the mocked fetch was called with the expected URL.
@@ -184,11 +183,10 @@ The search will happen as if called without the \"@\"."
"Should ignore results that don't match the searched handle."
(with-mock
(mock (mastodon-http--get-json
- "https://instance.url/api/v1/accounts/search"
- '(("q" . "Gargron")))
- =>
- (vector ccc-profile-json gargron-profile-json))
-
+ "https://instance.url/api/v2/search"
+ '(("q" . "Gargron")
+ ("type" . "accounts")))
+ => `((accounts ,ccc-profile-json ,gargron-profile-json)))
(let ((mastodon-instance-url "https://instance.url"))
(should
(equal
@@ -200,9 +198,11 @@ The search will happen as if called without the \"@\"."
TODO: We need to decide if this is actually desired or not."
(with-mock
- (mock (mastodon-http--get-json *
- '(("q" . "gargron")))
- => (vector gargron-profile-json))
+ (mock (mastodon-http--get-json
+ "https://instance.url/api/v2/search"
+ '(("q" . "gargron")
+ ("type" . "accounts")))
+ => `((accounts ,ccc-profile-json ,gargron-profile-json)))
(let ((mastodon-instance-url "https://instance.url"))
(should
@@ -234,23 +234,23 @@ content generation in the function under test."
(with-mock
;; Don't start any image loading:
(mock (mastodon-media--inline-images * *) => nil)
- (if (version< emacs-version "27.1")
- (mock (image-type-available-p 'imagemagick) => t)
- (mock (image-transforms-p) => t))
- (mock (mastodon-http--get-json "https://instance.url/api/v1/accounts/1/statuses" nil)
+ ;; (if (version< emacs-version "27.1")
+ ;; (mock (image-type-available-p 'imagemagick) => t)
+ ;; (mock (image-transforms-p) => t))
+ (mock (mastodon-http--get-json * *) ;"https://instance.url/api/v1/accounts/1/statuses"
=>
gargon-statuses-json)
(mock (mastodon-profile--get-statuses-pinned *)
=>
- [])
- (mock (mastodon-profile--relationships-get "1")
+ ())
+ (mock (mastodon-profile--relationships-get *) ;"1")
=>
'(((id . "1") (following . :json-false) (showing_reblogs . :json-false) (notifying . :json-false) (followed_by . :json-false) (blocking . :json-false) (blocked_by . :json-false) (muting . :json-false) (muting_notifications . :json-false) (requested . :json-false) (domain_blocking . :json-false) (endorsed . :json-false) (note . ""))))
;; Let's not do formatting as that makes it hard to not rely on
;; window width and reflowing the text.
(mock (shr-render-region * *) => nil)
;; Don't perform the actual update call at the end.
- ;;(mock (mastodon-tl--timeline *))
+ ;; (mock (mastodon-tl--timeline *))
(mock (mastodon-profile--fetch-server-account-settings)
=> '(max_toot_chars 1312 privacy "public" display_name "Eugen" discoverable t locked :json-false bot :json-false sensitive :json-false language ""))
@@ -263,34 +263,41 @@ content generation in the function under test."
(should
(equal
- (buffer-substring-no-properties (point-min) (point-max))
+ (with-current-buffer "*mastodon-Gargron-statuses*"
+ (buffer-substring-no-properties (point-min) (point-max)))
(concat
"\n"
"[img] [img] \n"
"Eugen\n"
"@Gargron\n"
- " ------------\n"
+ " ――――――――――――\n"
"<p>Developer of Mastodon and administrator of mastodon.social. I post service announcements, development updates, and personal stuff.</p>\n"
"_ Patreon __ :: <a href=\"https://www.patreon.com/mastodon\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://www.</span><span class=\"\">patreon.com/mastodon</span><span class=\"invisible\"></span></a>_ Homepage _ :: <a href=\"https://zeonfederated.com\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"\">zeonfederated.com</span><span class=\"invisible\"></span></a>"
"\n"
"Joined March 2016"
- "\n\n"
- " ------------\n"
- " TOOTS: 70741 | FOLLOWERS: 470905 | FOLLOWING: 451\n"
- " ------------\n"
+ "\n\n "
+ mastodon-tl--horiz-bar
+ "\n"
+ " TOOTS: 70741 | FOLLOWERS: 470905 | FOLLOWING: 451\n "
+ mastodon-tl--horiz-bar
+ "\n"
+ "\n "
+ mastodon-tl--horiz-bar
+ "\n"
+ " TOOTS \n "
+ mastodon-tl--horiz-bar
"\n"
- " ------------\n"
- " TOOTS \n"
- " ------------\n"
"\n"
- "<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p> \n"
- " Eugen (@Gargron) 2021-11-11 11:11:11\n"
- " ------------\n"
+ "<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>\n"
+ " Eugen (@Gargron) 2021-11-11 12:11:11\n "
+ mastodon-tl--horiz-bar
+ " 0 ⭐ | 0 🔁 | 0 💬\n"
"\n"
"\n"
- "<p><span class=\"h-card\"><a href=\"https://social.bau-ha.us/@CCC\" class=\"u-url mention\">@<span>CCC</span></a></span> At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p> \n"
- " Eugen (@Gargron) 2021-11-11 00:00:00\n"
- " ------------\n"
+ "<p><span class=\"h-card\"><a href=\"https://social.bau-ha.us/@CCC\" class=\"u-url mention\">@<span>CCC</span></a></span> At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>\n"
+ " Eugen (@Gargron) 2021-11-11 01:00:00\n "
+ mastodon-tl--horiz-bar
+ " 0 ⭐ | 2 🔁 | 0 💬\n"
"\n"
)))