<commit_before>(ns linkification
  (:use clojure.test
        [statuses.views.common :only [linkify]]))

(deftest linkify-basic []
  (is (= (linkify "lorem ipsum") "lorem ipsum")))

(deftest linkify-uris []
  (is (=
      (linkify "lorem http://example.org ipsum")
      "lorem <a href='http://example.org'>http://example.org</a> ipsum"))
  (is (=
      (linkify "http://example.org lipsum")
      "<a href='http://example.org'>http://example.org</a> lipsum"))
  (is (=
      (linkify "lipsum http://example.org")
      "lipsum <a href='http://example.org'>http://example.org</a>")))

(deftest linkify-hashtags []
  (is (=
      (linkify "lorem #hashtag ipsum")
      "lorem #<a href='/statuses/updates?query=%23hashtag'>hashtag</a> ipsum"))
  (is (=
      (linkify "#hashtag lipsum")
      "#<a href='/statuses/updates?query=%23hashtag'>hashtag</a> lipsum"))
  (is (=
      (linkify "lipsum #hashtag")
      "lipsum #<a href='/statuses/updates?query=%23hashtag'>hashtag</a>")))

(deftest linkify-uris-with-fragment-identifier []
  (is (=
      (linkify "lorem http://example.org#anchor ipsum")
      "lorem <a href='http://example.org#anchor'>http://example.org#anchor</a> ipsum")))
  (is (=
      (linkify "#hashtag lipsum http://example.org#anchor-name")
      "#<a href='/statuses/updates?query=%23hashtag'>hashtag</a> lipsum <a href='http://example.org#anchor-name'>http://example.org#anchor-name</a>"))
  (is (=
      (linkify "lipsum http://example.org#anchor-name #hashtag")
      "lipsum <a href='http://example.org#anchor-name'>http://example.org#anchor-name</a> #<a href='/statuses/updates?query=%23hashtag'>hashtag</a>"))

(deftest linkify-email-addresses []
  (is (=
      (linkify "hello <EMAIL> how are you")
      "hello <a href='mailto:<EMAIL>'><EMAIL></a> how are you")))<commit_msg>Add tests for mention detection.<commit_after>(ns linkification
  (:use clojure.test
        [statuses.views.common :only [linkify]]))

(deftest linkify-basic []
  (is (= (linkify "lorem ipsum") "lorem ipsum")))

(deftest linkify-uris []
  (is (=
      (linkify "lorem http://example.org ipsum")
      "lorem <a href='http://example.org'>http://example.org</a> ipsum"))
  (is (=
      (linkify "http://example.org lipsum")
      "<a href='http://example.org'>http://example.org</a> lipsum"))
  (is (=
      (linkify "lipsum http://example.org")
      "lipsum <a href='http://example.org'>http://example.org</a>")))

(deftest linkify-hashtags []
  (is (=
      (linkify "lorem #hashtag ipsum")
      "lorem #<a href='/statuses/updates?query=%23hashtag'>hashtag</a> ipsum"))
  (is (=
      (linkify "#hashtag lipsum")
      "#<a href='/statuses/updates?query=%23hashtag'>hashtag</a> lipsum"))
  (is (=
      (linkify "lipsum #hashtag")
      "lipsum #<a href='/statuses/updates?query=%23hashtag'>hashtag</a>")))

(deftest linkify-uris-with-fragment-identifier []
  (is (=
      (linkify "lorem http://example.org#anchor ipsum")
      "lorem <a href='http://example.org#anchor'>http://example.org#anchor</a> ipsum")))
  (is (=
      (linkify "#hashtag lipsum http://example.org#anchor-name")
      "#<a href='/statuses/updates?query=%23hashtag'>hashtag</a> lipsum <a href='http://example.org#anchor-name'>http://example.org#anchor-name</a>"))
  (is (=
      (linkify "lipsum http://example.org#anchor-name #hashtag")
      "lipsum <a href='http://example.org#anchor-name'>http://example.org#anchor-name</a> #<a href='/statuses/updates?query=%23hashtag'>hashtag</a>"))

(deftest linkify-email-addresses []
  (is (=
      (linkify "hello <EMAIL> how are you")
      "hello <a href='mailto:<EMAIL>'><EMAIL></a> how are you")))

(deftest linkify-mentions []
  (is (=
      (linkify "@foo")
      "@<a href='/statuses/updates?author=foo'>foo</a>"))
  (is (=
      (linkify "@foo how are you")
      "@<a href='/statuses/updates?author=foo'>foo</a> how are you"))
  (is (=
      (linkify "how are you @foo")
      "how are you @<a href='/statuses/updates?author=foo'>foo</a>"))
  (is (=
      (linkify "nice to see @foo again")
      "nice to see @<a href='/statuses/updates?author=foo'>foo</a> again")))
{'fraction_non_alphanumeric': 0.216796875, 'fraction_numerical': 0.0048828125, 'mean_word_length': 3.6716077537058154, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 4, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4114118', 'n_tokens_mistral': 1584, 'n_tokens_neox': 1537, 'n_words': 267}