diff options
author | marty hiatt <martianhiatus@riseup.net> | 2023-10-28 11:36:58 +0200 |
---|---|---|
committer | marty hiatt <martianhiatus@riseup.net> | 2023-10-28 11:39:25 +0200 |
commit | b8d0c9b967fbc1e38e4012ad357a7f29c621acc1 (patch) | |
tree | ab3f5f4f697b6d3d5f330d2e33aa8fa118ac7778 /test | |
parent | 5f237982e53f0804f03f88d20eecab864ab575d3 (diff) |
triage: call cb on response. do-user-action-fun: check response data
this means the triage callback always needs to handle 1 arg.
Diffstat (limited to 'test')
-rw-r--r-- | test/mastodon-http-tests.el | 6 | ||||
-rw-r--r-- | test/mastodon-tl-tests.el | 102 | ||||
-rw-r--r-- | test/mastodon-toot-tests.el | 2 |
3 files changed, 61 insertions, 49 deletions
diff --git a/test/mastodon-http-tests.el b/test/mastodon-http-tests.el index b3a02bc..96f9304 100644 --- a/test/mastodon-http-tests.el +++ b/test/mastodon-http-tests.el @@ -62,11 +62,11 @@ Strict-Transport-Security: max-age=31536000 (let ((response-buffer (get-buffer-create "mastodon-http--triage-buffer"))) (with-current-buffer response-buffer - (erase-buffer) + (erase-buffer) (insert mastodon-http--example-200)) (should (equal (mastodon-http--triage response-buffer - (lambda () + (lambda (_) (message "success call"))) "success call")))) @@ -80,7 +80,7 @@ Strict-Transport-Security: max-age=31536000 (insert mastodon-http--example-400)) (should (equal (mastodon-http--triage response-buffer - (lambda () + (lambda (_) (message "success call"))) "Error 444: some unhappy complaint")))) diff --git a/test/mastodon-tl-tests.el b/test/mastodon-tl-tests.el index be72f66..2aa0505 100644 --- a/test/mastodon-tl-tests.el +++ b/test/mastodon-tl-tests.el @@ -1090,56 +1090,68 @@ correct value for following, as well as notifications enabled or disabled." (let ((response-buffer-true (current-buffer))) (insert mastodon-tl--follow-notify-true-response) (with-mock - (mock (mastodon-http--post url-follow-only nil) - => response-buffer-true) - (should - (equal - (mastodon-tl--do-user-action-function url-follow-only - user-name - user-handle - "follow") - "User some-user (@some-user@instance.url) followed!")) - (mock (mastodon-http--post url-mute nil) - => response-buffer-true) - (should - (equal - (mastodon-tl--do-user-action-function url-mute - user-name - user-handle - "mute") - "User some-user (@some-user@instance.url) muted!")) - (mock (mastodon-http--post url-block nil) - => response-buffer-true) - (should - (equal - (mastodon-tl--do-user-action-function url-block - user-name - user-handle - "block") - "User some-user (@some-user@instance.url) blocked!"))) + (mock (mastodon-http--post url-follow-only nil) + => response-buffer-true) + (should + (equal + (mastodon-tl--do-user-action-function url-follow-only + user-name + user-handle + "follow") + "User some-user (@some-user@instance.url) followed!"))))) + (with-temp-buffer + (let ((response-buffer-true (current-buffer))) + (insert mastodon-tl--follow-notify-true-response) + (with-mock + (mock (mastodon-http--post url-mute nil) + => response-buffer-true) + (should + (equal + (mastodon-tl--do-user-action-function url-mute + user-name + user-handle + "mute") + "User some-user (@some-user@instance.url) muted!"))))) + (with-temp-buffer + (let ((response-buffer-true (current-buffer))) + (insert mastodon-tl--follow-notify-true-response) + (with-mock + (mock (mastodon-http--post url-block nil) + => response-buffer-true) + (should + (equal + (mastodon-tl--do-user-action-function url-block + user-name + user-handle + "block") + "User some-user (@some-user@instance.url) blocked!"))))) + (with-temp-buffer + (let ((response-buffer-true (current-buffer))) + (insert mastodon-tl--follow-notify-true-response) (with-mock - (mock (mastodon-http--post url-true nil) => response-buffer-true) - (should - (equal - (mastodon-tl--do-user-action-function url-true - user-name - user-handle - "follow" - "true") - "Receiving notifications for user some-user (@some-user@instance.url)!"))))) + (with-mock + (mock (mastodon-http--post url-true nil) => response-buffer-true) + (should + (equal + (mastodon-tl--do-user-action-function url-true + user-name + user-handle + "follow" + "true") + "Receiving notifications for user some-user (@some-user@instance.url)!")))))) (with-temp-buffer (let ((response-buffer-false (current-buffer))) (insert mastodon-tl--follow-notify-false-response) (with-mock - (mock (mastodon-http--post url-false nil) => response-buffer-false) - (should - (equal - (mastodon-tl--do-user-action-function url-false - user-name - user-handle - "follow" - "false") - "Not receiving notifications for user some-user (@some-user@instance.url)!"))))))) + (mock (mastodon-http--post url-false nil) => response-buffer-false) + (should + (equal + (mastodon-tl--do-user-action-function url-false + user-name + user-handle + "follow" + "false") + "Not receiving notifications for user some-user (@some-user@instance.url)!"))))))) (ert-deftest mastodon-tl--report-to-mods-params-alist () "" diff --git a/test/mastodon-toot-tests.el b/test/mastodon-toot-tests.el index 5efe2e1..6133453 100644 --- a/test/mastodon-toot-tests.el +++ b/test/mastodon-toot-tests.el @@ -180,7 +180,7 @@ mention string." => "https://example.space/statuses/61208/pin") (mock (mastodon-http--post "https://example.space/statuses/61208/pin") => pin-response) - (should (equal (mastodon-toot--action "pin" (lambda () + (should (equal (mastodon-toot--action "pin" (lambda (_) (message "Toot pinned!"))) "Toot pinned!")))))) |