Skip to content

Commit 61fc1d3

Browse files
committed
Adds test
1 parent 36e33e4 commit 61fc1d3

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/test_core/test_events.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,36 @@ def outer_click_is_not_triggered(event):
221221
await inner.click()
222222

223223
await poll(lambda: clicked.current).until_is(True)
224+
225+
226+
async def test_javascript_event(display: DisplayFixture):
227+
@reactpy.component
228+
def App():
229+
return reactpy.html.div(
230+
reactpy.html.div(
231+
reactpy.html.button(
232+
{
233+
"id": "the-button",
234+
"onClick": """javascript: () => {
235+
let parent = document.getElementById("the-parent");
236+
parent.appendChild(document.createElement("div"));
237+
}""",
238+
},
239+
"Click Me",
240+
),
241+
reactpy.html.div({"id": "the-parent"}),
242+
)
243+
)
244+
245+
await display.show(lambda: App())
246+
247+
button = await display.page.wait_for_selector("#the-button", state="attached")
248+
await button.click()
249+
await button.click()
250+
await button.click()
251+
parent = await display.page.wait_for_selector(
252+
"#the-parent", state="attached", timeout=0
253+
)
254+
generated_divs = await parent.query_selector_all("div")
255+
256+
assert len(generated_divs) == 3

0 commit comments

Comments
 (0)