# Path: gitmostwanted/lib/text.py
# class TextWithoutSmilies:
#     pattern = r'\s*:[a-z0-9_-]+:\s*'
# 
#     def __init__(self, text: str):
#         self.__text = text
# 
#     def __str__(self):
#         return re.sub(self.pattern, ' ', self.__text).strip()
# 
# class TextNormalized:
#     def __init__(self, text: str):
#         self.__text = unicodedata.normalize('NFC', text)
# 
#     def __str__(self):
#         return self.__text.encode(errors='ignore').decode()


from unittest import TestCase
from gitmostwanted.lib.text import TextWithoutSmilies, TextNormalized


class LibTextWithoutSmiliesTestCase(TestCase):
    def test_filter_smilies(self):
        tpls = ['a {} b', '{} a b', 'a b {}']
        for smile in [':point_up_2:', ':expressionless:', ':-1:']:
            for tpl in tpls:
                self.assertEqual('a b', str(TextWithoutSmilies(tpl.format(smile))))
        self.assertEqual(':hallo world:', str(TextWithoutSmilies(':hallo world:')))


class LibTextNormalizeTestCase(TestCase):
    def test_filter_invalid_chars(self):
        text = 'hello {} world'.format(u'\u0061\u0301')

# Path: gitmostwanted/lib/text.py
# class TextWithoutSmilies:
#     pattern = r'\s*:[a-z0-9_-]+:\s*'
# 
#     def __init__(self, text: str):
#         self.__text = text
# 
#     def __str__(self):
#         return re.sub(self.pattern, ' ', self.__text).strip()
# 
# class TextNormalized:
#     def __init__(self, text: str):
#         self.__text = unicodedata.normalize('NFC', text)
# 
#     def __str__(self):
#         return self.__text.encode(errors='ignore').decode()


# Path: tests/unit/lib/test_text.py
from unittest import TestCase
from gitmostwanted.lib.text import TextWithoutSmilies, TextNormalized



class LibTextWithoutSmiliesTestCase(TestCase):
    def test_filter_smilies(self):
        tpls = ['a {} b', '{} a b', 'a b {}']
        for smile in [':point_up_2:', ':expressionless:', ':-1:']:
            for tpl in tpls:
                self.assertEqual('a b', str(TextWithoutSmilies(tpl.format(smile))))
        self.assertEqual(':hallo world:', str(TextWithoutSmilies(':hallo world:')))


class LibTextNormalizeTestCase(TestCase):
    def test_filter_invalid_chars(self):
        text = 'hello {} world'.format(u'\u0061\u0301')

        self.assertEqual('hello á world', str(TextNormalized(text)))