test_json_editor.py 551 B

12345678910111213141516171819
  1. from nicegui import ui
  2. from nicegui.testing import Screen
  3. def test_json_editor_methods(screen: Screen):
  4. editor = ui.json_editor({'content': {'json': {'a': 1, 'b': 2}}})
  5. async def get_data():
  6. data = await editor.run_editor_method('get')
  7. ui.label(f'Data: {data}')
  8. ui.button('Get Data', on_click=get_data)
  9. screen.open('/')
  10. screen.should_contain('text')
  11. screen.should_contain('tree')
  12. screen.should_contain('table')
  13. screen.click('Get Data')
  14. screen.should_contain("Data: {'json': {'a': 1, 'b': 2}}")