diff options
author | Dmitry Osipov <dosipov@microsoft.com> | 2022-12-01 10:54:10 +0100 |
---|---|---|
committer | Dmitry Osipov <dosipov@microsoft.com> | 2022-12-01 10:54:10 +0100 |
commit | 5dddfbe7ca90cfb0026dfadc24f98703f0e6c661 (patch) | |
tree | 047e6a50038b12d2a2f69023b6d4305ad9d367f7 /test | |
parent | 1e4a661df8b3e07847e9d368f41fa775bf3442a7 (diff) |
Move mentions concatenation into a function for a reply.
Diffstat (limited to 'test')
-rw-r--r-- | test/mastodon-toot-tests.el | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/test/mastodon-toot-tests.el b/test/mastodon-toot-tests.el index 5d4ef03..69333c0 100644 --- a/test/mastodon-toot-tests.el +++ b/test/mastodon-toot-tests.el @@ -56,21 +56,33 @@ Transfer-Encoding: chunked") (username . "local") (url . "") (acct . "local"))]))) - (defconst mastodon-toot-no-mention '((mentions . []))) +(defconst mastodon-toot--multi-mention-extracted + '("local" "federated@federated.social" "federated@federated.cafe")) + (ert-deftest mastodon-toot--multi-mentions () "Should build a correct mention string from the test toot data. Even the local name \"local\" gets a domain name added." (let ((mastodon-auth--acct-alist '(("https://local.social". "null"))) (mastodon-instance-url "https://local.social")) - (should (string= + (should (equal (mastodon-toot--mentions mastodon-toot--multi-mention) + '("local" "federated@federated.social" "federated@federated.cafe"))))) + +(ert-deftest mastodon-toot--multi-mentions-to-string () + "Should build a correct mention string from the test toot data. + +Even the local name \"local\" gets a domain name added." + (let ((mastodon-auth--acct-alist '(("https://local.social". "null"))) + (mastodon-instance-url "https://local.social")) + (should (string= + (mastodon-toot--mentions-to-string mastodon-toot--multi-mention-extracted) "@local@local.social @federated@federated.social @federated@federated.cafe")))) -(ert-deftest mastodon-toot--multi-mentions-with-name () +(ert-deftest mastodon-toot--multi-mentions-with-name-to-string () "Should build a correct mention string omitting self. Here \"local\" is the user themselves and gets omitted from the @@ -79,15 +91,24 @@ mention string." '(("https://local.social". "local"))) (mastodon-instance-url "https://local.social")) (should (string= - (mastodon-toot--mentions mastodon-toot--multi-mention) + (mastodon-toot--mentions-to-string mastodon-toot--multi-mention-extracted) "@federated@federated.social @federated@federated.cafe")))) +(ert-deftest mastodon-toot--no-mention-to-string () + "Should return and empty string." + (let ((mastodon-auth--acct-alist + '(("https://local.social". "local"))) + (mastodon-instance-url "https://local.social")) + (should (string= + (mastodon-toot--mentions-to-string nil) + "")))) + (ert-deftest mastodon-toot--no-mention () - "Should construct an empty mention string without mentions." + "Should construct an empty mention list without mentions." (let ((mastodon-auth--acct-alist '(("https://local.social". "null"))) (mastodon-instance-url "https://local.social")) - (should (string= (mastodon-toot--mentions mastodon-toot-no-mention) "")))) + (should (equal (mastodon-toot--mentions mastodon-toot-no-mention) nil)))) ;; TODO: test y-or-no-p with mastodon-toot--cancel (ert-deftest mastodon-toot--kill () |