|
12 | 12 | assert_reactpy_did_not_log, |
13 | 13 | poll, |
14 | 14 | ) |
15 | | -from reactpy.web.module import NAME_SOURCE, WebModule |
16 | 15 | from reactpy.types import JavaScript |
| 16 | +from reactpy.web.module import NAME_SOURCE, WebModule |
17 | 17 |
|
18 | 18 | JS_FIXTURES_DIR = Path(__file__).parent / "js_fixtures" |
19 | 19 |
|
@@ -390,53 +390,25 @@ async def test_subcomponent_notation_as_obj_attrs(display: DisplayFixture): |
390 | 390 | assert len(form_label) == 1 |
391 | 391 |
|
392 | 392 |
|
393 | | -async def test_ag_grid_table(display: DisplayFixture): |
| 393 | +async def test_callable_prop_with_javacript(display: DisplayFixture): |
394 | 394 | module = reactpy.web.module_from_file( |
395 | | - "ag-grid-react", JS_FIXTURES_DIR / "ag-grid-react.js" |
| 395 | + "callable-prop", JS_FIXTURES_DIR / "callable-prop.js" |
396 | 396 | ) |
397 | | - AgGridReact = reactpy.web.export(module, "AgGridReact") |
| 397 | + Component = reactpy.web.export(module, "Component") |
398 | 398 |
|
399 | 399 | @reactpy.component |
400 | 400 | def App(): |
401 | | - dummy_bool, set_dummy_bool = reactpy.hooks.use_state(False) |
402 | | - row_data, set_row_data = reactpy.hooks.use_state([ |
403 | | - { "make": "Tesla", "model": "Model Y", "price": 64950, "electric": True }, |
404 | | - { "make": "Ford", "model": "F-Series", "price": 33850, "electric": False }, |
405 | | - { "make": "Toyota", "model": "Corolla", "price": 29600, "electric": False }, |
406 | | - ]) |
407 | | - col_defs, set_col_defs = reactpy.hooks.use_state([ |
408 | | - { "field": "make" }, |
409 | | - { "field": "model" }, |
410 | | - { "field": "price" }, |
411 | | - { "field": "electric" }, |
412 | | - ]) |
413 | | - default_col_def = {"flex": 1} |
414 | | - row_selection = reactpy.hooks.use_memo(lambda: {"mode": "singleRow"}) |
415 | | - |
416 | | - return reactpy.html.div( |
417 | | - {"id": "the-parent", "style": {"height": "100vh", "width": "100vw"}, "class": "ag-theme-quartz"}, |
418 | | - AgGridReact({ |
419 | | - "style": {"height": "500px"}, |
420 | | - "rowData": row_data, |
421 | | - "columnDefs": col_defs, |
422 | | - "defaultColDef": default_col_def, |
423 | | - "selection": row_selection, |
424 | | - "onRowSelected": lambda x: set_dummy_bool(not dummy_bool), |
425 | | - "getRowId": JavaScript("(params) => String(params.data.model);") |
426 | | - }) |
| 401 | + return Component( |
| 402 | + { |
| 403 | + "id": "my-div", |
| 404 | + "setText": JavaScript('(prefixText) => prefixText + "TEST 123"'), |
| 405 | + } |
427 | 406 | ) |
428 | 407 |
|
429 | | - await display.show( |
430 | | - lambda: App() |
431 | | - ) |
| 408 | + await display.show(lambda: App()) |
432 | 409 |
|
433 | | - table_body = await display.page.wait_for_selector(".ag-body-viewport", state="attached") |
434 | | - checkboxes = await table_body.query_selector_all(".ag-checkbox-input") |
435 | | - await checkboxes[0].click() |
436 | | - # Regrab checkboxes, since they should rerender |
437 | | - checkboxes = await table_body.query_selector_all(".ag-checkbox-input") |
438 | | - checked = await checkboxes[0].is_checked() |
439 | | - assert checked is True |
| 410 | + my_div = await display.page.wait_for_selector("#my-div", state="attached") |
| 411 | + assert await my_div.inner_text() == "PREFIX TEXT: TEST 123" |
440 | 412 |
|
441 | 413 |
|
442 | 414 | def test_module_from_string(): |
|
0 commit comments