aboutsummaryrefslogtreecommitdiff
path: root/test/mastodon-toot-tests.el
blob: ca04ae82040571f3167c34591c5eb73ecb369047 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(require 'el-mock)

(ert-deftest mastodon-toot:cancel ()
  (with-mock
    (mock (kill-buffer-and-window))
    (should (eq nil (mastodon-toot--cancel)))))

(ert-deftest mastodon-toot:send ()
  (with-mock
    (stub mastodon--api-for => "https://instance/api/v/statuses")
    (stub buffer-string => "This is a test toot")
    (stub kill-buffer-and-window)
    (stub mastodon-auth--access-token => "access-token-string")
    (mock (mastodon--http-post "https://instance/api/v/statuses"
                               'mastodon-toot--send-triage
                               '(("status" . "This is a test toot"))
                               '(("Authorization" . "Bearer access-token-string"))))
    (should (eq nil (mastodon-toot--send)))))

(ert-deftest mastodon-toot:send-triage ()
  (with-mock
    (mock (mastodon--http-response-triage "status"
                                          (lambda () (switch-to-buffer (current-buffer)))))
    (should (eq nil (mastodon-toot--send-triage "status")))))