test_menu.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Copyright 2021-2024 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. from taipy.gui import Gui
  12. def test_menu_md(gui: Gui, test_client, helpers):
  13. gui._bind_var_val("lov", ["Item 1", "Item 2", "Item 3", "Item 4"])
  14. md_string = "<|menu|lov={lov}|on_action=on_menu_action|>"
  15. expected_list = [
  16. "<MenuCtl",
  17. 'libClassName="taipy-menu"',
  18. 'defaultLov="[&quot;Item 1&quot;, &quot;Item 2&quot;, &quot;Item 3&quot;, &quot;Item 4&quot;]"',
  19. "lov={_TpL_tpec_TpExPr_lov_TPMDL_0}",
  20. 'onAction="on_menu_action"',
  21. 'updateVars="lov=_TpL_tpec_TpExPr_lov_TPMDL_0"',
  22. ]
  23. helpers.test_control_md(gui, md_string, expected_list)
  24. def test_menu_html(gui: Gui, test_client, helpers):
  25. gui._bind_var_val("lov", ["Item 1", "Item 2", "Item 3", "Item 4"])
  26. html_string = '<taipy:menu lov="{lov}" />'
  27. expected_list = [
  28. "<MenuCtl",
  29. 'libClassName="taipy-menu"',
  30. 'defaultLov="[&quot;Item 1&quot;, &quot;Item 2&quot;, &quot;Item 3&quot;, &quot;Item 4&quot;]"',
  31. "lov={_TpL_tpec_TpExPr_lov_TPMDL_0}",
  32. 'updateVars="lov=_TpL_tpec_TpExPr_lov_TPMDL_0"',
  33. ]
  34. helpers.test_control_html(gui, html_string, expected_list)