|
@@ -1355,3 +1355,32 @@ def test_app_state_determination():
|
|
# Referencing an event handler enables state.
|
|
# Referencing an event handler enables state.
|
|
a4.add_page(rx.box(rx.button("Click", on_click=rx.console_log(""))), route="/")
|
|
a4.add_page(rx.box(rx.button("Click", on_click=rx.console_log(""))), route="/")
|
|
assert a4.state is not None
|
|
assert a4.state is not None
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def test_add_page_component_returning_tuple():
|
|
|
|
+ """Test that a component or render method returning a
|
|
|
|
+ tuple is unpacked in a Fragment.
|
|
|
|
+ """
|
|
|
|
+ app = App()
|
|
|
|
+
|
|
|
|
+ def index():
|
|
|
|
+ return rx.text("first"), rx.text("second")
|
|
|
|
+
|
|
|
|
+ def page2():
|
|
|
|
+ return (rx.text("third"),)
|
|
|
|
+
|
|
|
|
+ app.add_page(index) # type: ignore
|
|
|
|
+ app.add_page(page2) # type: ignore
|
|
|
|
+
|
|
|
|
+ assert isinstance((fragment_wrapper := app.pages["index"].children[0]), Fragment)
|
|
|
|
+ assert isinstance((first_text := fragment_wrapper.children[0]), Text)
|
|
|
|
+ assert str(first_text.children[0].contents) == "{`first`}" # type: ignore
|
|
|
|
+ assert isinstance((second_text := fragment_wrapper.children[1]), Text)
|
|
|
|
+ assert str(second_text.children[0].contents) == "{`second`}" # type: ignore
|
|
|
|
+
|
|
|
|
+ # Test page with trailing comma.
|
|
|
|
+ assert isinstance(
|
|
|
|
+ (page2_fragment_wrapper := app.pages["page2"].children[0]), Fragment
|
|
|
|
+ )
|
|
|
|
+ assert isinstance((third_text := page2_fragment_wrapper.children[0]), Text)
|
|
|
|
+ assert str(third_text.children[0].contents) == "{`third`}" # type: ignore
|