aboutsummaryrefslogtreecommitdiff
path: root/test/mastodon-toot-tests.el
blob: 3e2553647fa8a9701855dbae7c2039cb3f7e5352 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
(require 'el-mock)

(defconst mastodon-toot-multi-mention
  '((mentions .
              [((id . "1")
                (username . "federated")
                (url . "https://site.cafe/@federated")
                (acct . "federated@federated.cafe"))
               ((id . "1")
                (username . "federated")
                (url . "https://site.cafe/@federated")
                (acct . "federated@federated.social"))
               ((id . "1")
                (username . "local")
                (url . "")
                (acct . "local"))])))

(defconst mastodon-toot-no-mention
  '((mentions . [])))

(ert-deftest toot-multi-mentions ()
  (let ((mastodon-auth--acct-alist '(("https://local.social". "null")))
        (mastodon-instance-url "https://local.social"))    
    (should (string=
             (mastodon-toot--mentions mastodon-toot-multi-mention)
             "@local@local.social @federated@federated.social @federated@federated.cafe "))))

(ert-deftest toot-multi-mentions-with-name ()
  (let ((mastodon-auth--acct-alist
         '(("https://local.social". "local")))
        (mastodon-instance-url "https://local.social"))
    (should (string=
             (mastodon-toot--mentions mastodon-toot-multi-mention)
             "@federated@federated.social @federated@federated.cafe "))))

(ert-deftest toot-no-mention ()
  (let ((mastodon-auth--acct-alist
         '(("https://local.social". "null")))
        (mastodon-instance-url "https://local.social"))    
    (should (string= (mastodon-toot--mentions mastodon-toot-no-mention) ""))))

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