from django.test import SimpleTestCase

from jobs.templatetags.jobs_tags import linkify, linkify_br


class LinkifyFilterTests(SimpleTestCase):
    def test_linkify_makes_url_clickable(self):
        html = linkify('Apply at https://example.com/apply now')
        self.assertIn('href="https://example.com/apply"', html)
        self.assertIn('target="_blank"', html)
        self.assertIn('rel="noopener noreferrer"', html)

    def test_linkify_br_preserves_line_breaks(self):
        html = linkify_br('Apply here:\nhttps://example.com/apply')
        self.assertIn('<br', html)
        self.assertIn('href="https://example.com/apply"', html)

    def test_linkify_empty_value(self):
        self.assertEqual(linkify(''), '')
        self.assertEqual(linkify_br(None), '')
