diff options
author | Holger Durer <hdurer@google.com> | 2018-03-06 06:57:55 +0000 |
---|---|---|
committer | Johnson Denen <johnson.denen@gmail.com> | 2018-08-10 22:20:04 -0400 |
commit | 02470346206894f0c261dc53447db4ac72700031 (patch) | |
tree | 7767f87a99ededc95159cb83a38fe84605babd5e /test/mastodon-tl-tests.el | |
parent | ae8dabda04e377a6ac22cb854e4844f68073f533 (diff) |
Recognise hashtag links and make them link to our own tag browsing functionality instead.
Diffstat (limited to 'test/mastodon-tl-tests.el')
-rw-r--r-- | test/mastodon-tl-tests.el | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/mastodon-tl-tests.el b/test/mastodon-tl-tests.el index 189916d..6e75d26 100644 --- a/test/mastodon-tl-tests.el +++ b/test/mastodon-tl-tests.el @@ -821,3 +821,50 @@ constant." ;; The body is invisible again: (should (eq t (get-text-property body-position 'invisible)))))) + +(ert-deftest mastodon-tl--hashtag () + "Should recognise hashtags in a toot and add the required properties to it." + ;; Travis's Emacs doesn't have libxml so we fake things by inputting + ;; propertized text and stubbing shr-render-region + (let* ((fake-input-text + (concat "Tag:" + (propertize + "sampletag" + 'shr-url "https://example.space/tags/sampletag" + 'keymap shr-map + 'help-echo "https://example.space/tags/sampletag") + " some text after")) + (rendered (with-mock + (stub shr-render-region => nil) + (mastodon-tl--render-text + fake-input-text + mastodon-tl-test-base-toot))) + (tag-location 7)) + (should (eq (get-text-property tag-location 'mastodon-tab-stop rendered) + 'hashtag)) + (should (equal (get-text-property tag-location 'mastodon-tag rendered) + "sampletag")) + (should (equal (get-text-property tag-location 'help-echo rendered) + "Browse tag #sampletag")))) + +(ert-deftest mastodon-tl--extract-hashtag-from-url-mastodon-link () + (should (equal (mastodon-tl--extract-hashtag-from-url + "https://example.org/tags/foo" + "https://example.org") + "foo"))) + +(ert-deftest mastodon-tl--extract-hashtag-from-url-other-link () + (should (equal (mastodon-tl--extract-hashtag-from-url + "https://example.org/tag/foo" + "https://example.org") + "foo"))) + +(ert-deftest mastodon-tl--extract-hashtag-from-url-wrong-instance () + (should (null (mastodon-tl--extract-hashtag-from-url + "https://example.org/tags/foo" + "https://other.example.org")))) + +(ert-deftest mastodon-tl--extract-hashtag-from-url-not-tag () + (should (null (mastodon-tl--extract-hashtag-from-url + "https://example.org/@userid" + "https://example.org")))) |