diff options
author | mousebot <mousebot@riseup.net> | 2021-12-20 22:32:08 +0100 |
---|---|---|
committer | mousebot <mousebot@riseup.net> | 2021-12-20 22:32:08 +0100 |
commit | 91e286e04b2a8a181955b40ab3934214076e33d2 (patch) | |
tree | cb8f03ff9b71100bd2b289d8ffd670fa94c4b9cb | |
parent | 7d93e1f38332d03de0d935c7460bf3eb2821bf7d (diff) |
making a start on pinned toot tests
-rw-r--r-- | test/mastodon-toot-tests.el | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/test/mastodon-toot-tests.el b/test/mastodon-toot-tests.el index ac56015..0c31029 100644 --- a/test/mastodon-toot-tests.el +++ b/test/mastodon-toot-tests.el @@ -98,6 +98,7 @@ mention string." (mock-verify))) (ert-deftest mastodon-toot--own-toot-p-fail () + "Should not return t if not own toot." (let ((toot mastodon-toot-test-base-toot)) (with-mock (mock (mastodon-auth--user-acct) => "joebogus@bogus.space") @@ -105,6 +106,7 @@ mention string." t)))))) (ert-deftest mastodon-toot--own-toot-p () + "Should return 't' if own toot." (let ((toot mastodon-toot-test-base-toot)) (with-mock (mock (mastodon-auth--user-acct) => "acct42@example.space") @@ -128,7 +130,7 @@ mention string." (let ((delete-response (current-buffer)) (toot mastodon-toot-test-base-toot)) (with-mock - (mock (mastodon-tl--property 'toot-json) => mastodon-toot-test-base-toot) + (mock (mastodon-tl--property 'toot-json) => toot) ;; (mock (mastodon-toot--own-toot-p toot) => t) (mock (mastodon-auth--user-acct) => "acct42@example.space") (mock (mastodon-http--api (format "statuses/61208")) @@ -138,3 +140,31 @@ mention string." => delete-response) (should (equal (mastodon-toot--delete-toot) "Toot deleted!")))))) + +(ert-deftest mastodon-toot-action-pin () + "Should return callback provided by `mastodon-toot--pin-toot-toggle'." + (with-temp-buffer + (insert mastodon-toot--200-html) + (let ((pin-response (current-buffer)) + (toot mastodon-toot-test-base-toot) + (id 61208)) + (with-mock + (mock (mastodon-tl--property 'base-toot-id) => id) + (mock (mastodon-http--api "statuses/61208/pin") + => "https://example.space/statuses/61208/pin") + (mock (mastodon-http--post "https://example.space/statuses/61208/pin" nil nil) + => pin-response) + (should (equal (mastodon-toot--action "pin" (lambda () + (message "Toot pinned!"))) + "Toot pinned!")))))) + +(ert-deftest mastodon-toot--pin-toot-fail () + (with-temp-buffer + (insert mastodon-toot--200-html) + (let ((pin-response (current-buffer)) + (toot mastodon-toot-test-base-toot)) + (with-mock + (mock (mastodon-tl--property 'toot-json) => toot) + (mock (mastodon-auth--user-acct) => "joebogus@example.space") + (should (equal (mastodon-toot--pin-toot-toggle) + "You can only pin your own toots.")))))) |