def test_canonical_value_in_cascading_dropdown( choices, default_value, expected_canonical, ): assert vs.CascadingDropdown( choices=choices).canonical_value() == expected_canonical
def test_default_value_in_cascading_dropdown( choices, default_value, expected_default, ): assert vs.CascadingDropdown( choices=choices).default_value() == expected_default
def test_transform_value_in_cascading_dropdown(): valuespec = vs.CascadingDropdown(choices=[ ("a", "Title a", vs.TextInput()), ("b", "Title b", vs.Transform( vs.TextInput(), forth=lambda x: x if x == "lala" else x.upper(), back=lambda x: x + "aaa", )), ]) assert valuespec.transform_value(("a", "abc")) == ("a", "abc") assert valuespec.transform_value(("b", "lala")) == ("b", "lalaaaa") assert valuespec.transform_value(("b", "AAA")) == ("b", "AAAaaa")