from django.test import TestCase
from djc_core_html_parser import set_html_attributes
from .django_test_setup import setup_test_config
setup_test_config({"autodiscover": False})
# This same set of tests is also found in djc_html_parser, to ensure that
# this implementation can be replaced with the djc_html_parser's Rust-based implementation
class TestHTMLParser(TestCase):
def test_basic_transformation(self):
html = "
""",
)
# Verify attribute capturing
self.assertEqual(len(captured), 3)
# Root element should have both root and all attributes
self.assertEqual(captured["123"], ["data-root", "data-v-123"])
# Non-root elements should only have all attributes
self.assertEqual(captured["456"], ["data-v-123"])
self.assertEqual(captured["789"], ["data-v-123"])
def test_whitespace_preservation(self):
html = """