MCPcopy
hub / github.com/reflex-dev/reflex / test_style_update_with_var_data

Function test_style_update_with_var_data

tests/units/test_style.py:470–493  ·  view source on GitHub ↗

Test that .update with a Style containing VarData works.

()

Source from the content-addressed store, hash-verified

468
469
470def test_style_update_with_var_data():
471 """Test that .update with a Style containing VarData works."""
472 red_var = LiteralVar.create("red")._replace(
473 merge_var_data=VarData(hooks={"const red = true": None}),
474 )
475 blue_var = LiteralVar.create("blue")._replace(
476 merge_var_data=VarData(hooks={"const blue = true": None}),
477 )
478
479 s1 = Style({
480 "color": red_var,
481 })
482 s2 = Style()
483 s2.update(s1, background_color=f"{blue_var}ish")
484 assert str(LiteralVar.create(s2)) == str(
485 LiteralVar.create({"color": "red", "backgroundColor": "blueish"})
486 )
487 assert s2._var_data is not None
488 assert "const red = true" in s2._var_data.hooks
489 assert "const blue = true" in s2._var_data.hooks
490
491 s3 = s1 | s2
492 assert s3._var_data is not None
493 assert "_varData" not in s3
494
495
496def test_component_as_css_value_raises_error():

Callers

nothing calls this directly

Calls 5

updateMethod · 0.95
VarDataClass · 0.90
StyleClass · 0.90
_replaceMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected