aboutsummaryrefslogtreecommitdiff
path: root/test/mastodon-toot-tests.el
diff options
context:
space:
mode:
authormousebot <mousebot@riseup.net>2021-12-20 21:30:22 +0100
committermousebot <mousebot@riseup.net>2021-12-20 21:32:47 +0100
commit9620244cb4ece4e5503a3f5a6c73b948afa5ff74 (patch)
tree93aebc8ef4934926fb01b3b973a8f7edacf6d49c /test/mastodon-toot-tests.el
parent7e3269835aace403d6462655dfa79d9a3060b02a (diff)
tests for own-toot-p
Diffstat (limited to 'test/mastodon-toot-tests.el')
-rw-r--r--test/mastodon-toot-tests.el57
1 files changed, 36 insertions, 21 deletions
diff --git a/test/mastodon-toot-tests.el b/test/mastodon-toot-tests.el
index f2c7b8f..ac56015 100644
--- a/test/mastodon-toot-tests.el
+++ b/test/mastodon-toot-tests.el
@@ -97,29 +97,44 @@ mention string."
(mastodon-toot--kill)
(mock-verify)))
+(ert-deftest mastodon-toot--own-toot-p-fail ()
+ (let ((toot mastodon-toot-test-base-toot))
+ (with-mock
+ (mock (mastodon-auth--user-acct) => "joebogus@bogus.space")
+ (should (not (equal (mastodon-toot--own-toot-p toot)
+ t))))))
+
+(ert-deftest mastodon-toot--own-toot-p ()
+ (let ((toot mastodon-toot-test-base-toot))
+ (with-mock
+ (mock (mastodon-auth--user-acct) => "acct42@example.space")
+ (should (equal (mastodon-toot--own-toot-p toot)
+ t)))))
+
(ert-deftest mastodon-toot--delete-toot-fail ()
"Should refuse to delete toot."
- (let ((toot mastodon-toot-test-base-toot))
- (with-mock
- (mock (mastodon-auth--user-acct) => "joebogus")
- ;; (mock (mastodon-toot--own-toot-p toot) => nil)
- (mock (mastodon-tl--property 'toot-json) => mastodon-toot-test-base-toot)
- (should (equal (mastodon-toot--delete-toot)
- "You can only delete (and redraft) your own toots.")))))
+ (let ((toot mastodon-toot-test-base-toot))
+ (with-mock
+ (mock (mastodon-auth--user-acct) => "joebogus")
+ ;; (mock (mastodon-toot--own-toot-p toot) => nil)
+ (mock (mastodon-tl--property 'toot-json) => mastodon-toot-test-base-toot)
+ (should (equal (mastodon-toot--delete-toot)
+ "You can only delete (and redraft) your own toots.")))))
(ert-deftest mastodon-toot--delete-toot ()
"Should return correct triaged response to a legitimate DELETE request."
- (with-temp-buffer
- (insert mastodon-toot--200-html)
- (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-toot--own-toot-p toot) => t)
- (mock (mastodon-http--api (format "statuses/61208"))
- => "https://local.social/statuses/61208")
- (mock (y-or-n-p "Delete this toot? ") => t)
- (mock (mastodon-http--delete "https://local.social/statuses/61208")
- => delete-response)
- (should (equal (mastodon-toot--delete-toot)
- "Toot deleted!"))))))
+ (with-temp-buffer
+ (insert mastodon-toot--200-html)
+ (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-toot--own-toot-p toot) => t)
+ (mock (mastodon-auth--user-acct) => "acct42@example.space")
+ (mock (mastodon-http--api (format "statuses/61208"))
+ => "https://example.space/statuses/61208")
+ (mock (y-or-n-p "Delete this toot? ") => t)
+ (mock (mastodon-http--delete "https://example.space/statuses/61208")
+ => delete-response)
+ (should (equal (mastodon-toot--delete-toot)
+ "Toot deleted!"))))))