Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def simple_param_element(self, tag):
return idom.vdom(tag)
idom.vdom("div", [idom.vdom("div"), 1], (idom.vdom("div"), 2)),
{
"tagName": "div",
"children": [{"tagName": "div"}, 1, {"tagName": "div"}, 2],
},
),
(
# multiple dictionaries of attributes are merged
idom.vdom("div", {"width": "30px"}, {"height": "20px"}),
{"tagName": "div", "attributes": {"width": "30px", "height": "20px"}},
),
(
idom.vdom(
"div",
{"width": "30px"},
{"height": "20px"},
[idom.vdom("div"), 1],
async def SimpleElement(self, tag):
return idom.vdom(tag)
idom.vdom("div", map(lambda x: x ** 2, [1, 2, 3])),
{"tagName": "div", "children": [1, 4, 9]},
),
],
)
def test_simple_node_construction(actual, expected):
assert actual == expected
async def simple_stateful_element(self, tag):
return idom.vdom(tag)
idom.vdom("div", event_handlers=fake_events),
{"tagName": "div", "eventHandlers": fake_events},
),
(
idom.vdom("div", idom.html.h1("hello"), idom.html.h2("world")),
{
"tagName": "div",
"children": [
{"tagName": "h1", "children": ["hello"]},
{"tagName": "h2", "children": ["world"]},
],
},
),
(
idom.vdom("div", {"tagName": "div"}),
{"tagName": "div", "children": [{"tagName": "div"}]},
),
def test_vdom_attribute_arguments_come_before_children():
with pytest.raises(ValueError):
idom.vdom("div", ["c1", "c2"], {"attr": 1})
idom.vdom("div", {"width": "30px"}, {"height": "20px"}),
{"tagName": "div", "attributes": {"width": "30px", "height": "20px"}},
),
(
idom.vdom(
"div",
{"width": "30px"},
{"height": "20px"},
[idom.vdom("div"), 1],
(idom.vdom("div"), 2),
),
{
"tagName": "div",
"children": [{"tagName": "div"}, 1, {"tagName": "div"}, 2],
"attributes": {"width": "30px", "height": "20px"},
},
),
idom.vdom("div", idom.html.h1("hello"), idom.html.h2("world")),
{
"tagName": "div",
"children": [
{"tagName": "h1", "children": ["hello"]},
{"tagName": "h2", "children": ["world"]},
],
},
),
(
idom.vdom("div", {"tagName": "div"}),
{"tagName": "div", "children": [{"tagName": "div"}]},
),
(
idom.vdom("div", (i for i in range(3))),
{"tagName": "div", "children": [0, 1, 2]},
),