aboutsummaryrefslogtreecommitdiff
path: root/test/mastodon-toot-tests.el
diff options
context:
space:
mode:
authormousebot <mousebot@riseup.net>2021-12-20 20:25:43 +0100
committermousebot <mousebot@riseup.net>2021-12-20 20:25:43 +0100
commitfff33fa9206864f3bfc80f7725d76eecf074aaaa (patch)
treeea6f0a9ab34540c5fc84d93f418c3e514193ff39 /test/mastodon-toot-tests.el
parent4cec0aa24f717489be5d1959682d0c14b349d5af (diff)
delete toot test use temp buffer
Diffstat (limited to 'test/mastodon-toot-tests.el')
-rw-r--r--test/mastodon-toot-tests.el59
1 files changed, 44 insertions, 15 deletions
diff --git a/test/mastodon-toot-tests.el b/test/mastodon-toot-tests.el
index 31f95df..1ad2558 100644
--- a/test/mastodon-toot-tests.el
+++ b/test/mastodon-toot-tests.el
@@ -9,9 +9,38 @@ Date: Mon, 20 Dec 2021 13:42:29 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked")
+(defconst mastodon-toot-test-base-toot
+ '((id . 61208)
+ (created_at . "2017-04-24T19:01:02.000Z")
+ (in_reply_to_id)
+ (in_reply_to_account_id)
+ (sensitive . :json-false)
+ (spoiler_text . "")
+ (visibility . "public")
+ (account (id . 42)
+ (username . "acct42")
+ (acct . "acct42@example.space")
+ (display_name . "Account 42")
+ (locked . :json-false)
+ (created_at . "2017-04-01T00:00:00.000Z")
+ (followers_count . 99)
+ (following_count . 13)
+ (statuses_count . 101)
+ (note . "E"))
+ (media_attachments . [])
+ (mentions . [])
+ (tags . [])
+ (uri . "tag:example.space,2017-04-24:objectId=654321:objectType=Status")
+ (url . "https://example.space/users/acct42/updates/123456789")
+ (content . "<p>Just some text</p>")
+ (reblogs_count . 0)
+ (favourites_count . 0)
+ (reblog))
+ "A sample toot (parsed json)")
+
(defconst mastodon-toot--mock-toot
(propertize "here is a mock toot text."
- 'toot-json mastodon-tl-test-base-toot))
+ 'toot-json mastodon-toot-test-base-toot))
(defconst mastodon-toot--multi-mention
'((mentions .
@@ -78,17 +107,17 @@ mention string."
(ert-deftest mastodon-toot--delete-toot ()
"Should return correct triaged response to a DELETE request."
- (let ((delete-response (get-buffer-create "delete-200")))
- (with-current-buffer delete-response
- (insert mastodon-toot--200-html))
- (let ((toot mastodon-tl-test-base-toot))
- (with-mock
- (mock (mastodon-tl--property 'toot-json) => mastodon-tl-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-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!"))))))