()
| 72 | |
| 73 | |
| 74 | def test_html_to_vdom_transform(): |
| 75 | source = "<p>hello <a>world</a> and <a>universe</a>lmao</p>" |
| 76 | |
| 77 | def make_links_blue(node): |
| 78 | if node["tagName"] == "a": |
| 79 | node["attributes"] = {"style": {"color": "blue"}} |
| 80 | return node |
| 81 | |
| 82 | expected = { |
| 83 | "tagName": "p", |
| 84 | "children": [ |
| 85 | "hello ", |
| 86 | { |
| 87 | "tagName": "a", |
| 88 | "children": ["world"], |
| 89 | "attributes": {"style": {"color": "blue"}}, |
| 90 | }, |
| 91 | " and ", |
| 92 | { |
| 93 | "tagName": "a", |
| 94 | "children": ["universe"], |
| 95 | "attributes": {"style": {"color": "blue"}}, |
| 96 | }, |
| 97 | "lmao", |
| 98 | ], |
| 99 | } |
| 100 | |
| 101 | assert html_to_vdom(source, make_links_blue) == expected |
| 102 | |
| 103 | |
| 104 | def test_non_html_tag_behavior(): |
nothing calls this directly
no test coverage detected