11# This same set of tests is also found in django-components, to ensure that
22# this implementation can be replaced with the django-components' pure-python implementation
33
4- from djc_core_html_parser import transform_html
4+ from djc_core_html_parser import set_html_attributes
55from typing import Dict , List
66
77
88def test_basic_transformation ():
99 html = "<div><p>Hello</p></div>"
10- result , _ = transform_html (html , ["data-root" ], ["data-all" ])
10+ result , _ = set_html_attributes (html , ["data-root" ], ["data-all" ])
1111 expected = '<div data-root="" data-all=""><p data-all="">Hello</p></div>'
1212 assert result == expected
1313
1414
1515def test_multiple_roots ():
1616 html = "<div>First</div><span>Second</span>"
17- result , _ = transform_html (html , ["data-root" ], ["data-all" ])
17+ result , _ = set_html_attributes (html , ["data-root" ], ["data-all" ])
1818 expected = '<div data-root="" data-all="">First</div><span data-root="" data-all="">Second</span>'
1919 assert result == expected
2020
@@ -42,7 +42,7 @@ def test_complex_html():
4242 </footer>
4343 """
4444
45- result , _ = transform_html (html , ["data-root" ], ["data-all" , "data-v-123" ])
45+ result , _ = set_html_attributes (html , ["data-root" ], ["data-all" , "data-v-123" ])
4646 expected = """
4747 <div class="container" id="main" data-root="" data-all="" data-v-123="">
4848 <header class="flex" data-all="" data-v-123="">
@@ -76,7 +76,7 @@ def test_void_elements():
7676 ]
7777
7878 for input_html , expected in test_cases :
79- result , _ = transform_html (input_html , ["data-root" ], ["data-v-123" ])
79+ result , _ = set_html_attributes (input_html , ["data-root" ], ["data-v-123" ])
8080 assert result == expected
8181
8282
@@ -89,7 +89,7 @@ def test_html_head_with_meta():
8989 <meta name="description" content="Test">
9090 </head>"""
9191
92- result , _ = transform_html (html , ["data-root" ], ["data-v-123" ])
92+ result , _ = set_html_attributes (html , ["data-root" ], ["data-v-123" ])
9393 expected = """
9494 <head data-root="" data-v-123="">
9595 <meta charset="utf-8" data-v-123=""/>
@@ -110,7 +110,7 @@ def test_watch_attribute():
110110
111111 result : str
112112 captured : Dict [str , List [str ]]
113- result , captured = transform_html (html , ["data-root" ], ["data-v-123" ], watch_on_attribute = "data-id" )
113+ result , captured = set_html_attributes (html , ["data-root" ], ["data-v-123" ], watch_on_attribute = "data-id" )
114114 expected = """
115115 <div data-id="123" data-root="" data-v-123="">
116116 <p data-v-123="">Regular element</p>
@@ -140,7 +140,7 @@ def test_whitespace_preservation():
140140 <span> Text with spaces </span>
141141 </div>"""
142142
143- result , _ = transform_html (html , ["data-root" ], ["data-all" ])
143+ result , _ = set_html_attributes (html , ["data-root" ], ["data-all" ])
144144 expected = """<div data-root="" data-all="">
145145 <p data-all=""> Hello World </p>
146146 <span data-all=""> Text with spaces </span>
0 commit comments