import unittest
from textnode import TextNode, TextType

class TestTextNode(unittest.TestCase):
    def test_eq(self):
        # Test equality between two identical nodes
        node1 = TextNode("This is a text node", TextType.BOLD_TEXT)
        node2 = TextNode("This is a text node", TextType.BOLD_TEXT)
        self.assertEqual(node1, node2)

    def test_url(self):
        # Test that the URL is correctly assigned
        node = TextNode("This is link text", TextType.LINK_TEXT, "https://google.com")
        self.assertEqual(node.url, "https://google.com")

    def test_repr(self):
        # Test the string representation of a TextNode
        node = TextNode("Sample text", TextType.LINK_TEXT, "https://example.com")
        expected_repr = "TextNode(Sample text, link, https://example.com)"
        self.assertEqual(repr(node), expected_repr)

    def test_invalid_text_type(self):
        # Test that an invalid text_type raises an error
        with self.assertRaises(ValueError):
            TextNode("Invalid test", "invalid_type")

if __name__ == "__main__":
    unittest.main()

