(display: DisplayFixture)
| 107 | |
| 108 | |
| 109 | async def test_use_location(display: DisplayFixture): |
| 110 | location = reactpy.Ref() |
| 111 | |
| 112 | @poll |
| 113 | async def poll_location(): |
| 114 | """This needs to be async to allow the server to respond""" |
| 115 | return getattr(location, "current", None) |
| 116 | |
| 117 | @reactpy.component |
| 118 | def ShowRoute(): |
| 119 | location.current = reactpy.use_location() |
| 120 | return html.pre(str(location.current)) |
| 121 | |
| 122 | await display.show(ShowRoute) |
| 123 | |
| 124 | await poll_location.until_equals(Location("/", "")) |
| 125 | |
| 126 | for loc in [ |
| 127 | Location("/something", ""), |
| 128 | Location("/something/file.txt", ""), |
| 129 | Location("/another/something", ""), |
| 130 | Location("/another/something/file.txt", ""), |
| 131 | Location("/another/something/file.txt", "?key=value"), |
| 132 | Location("/another/something/file.txt", "?key1=value1&key2=value2"), |
| 133 | ]: |
| 134 | await display.goto(loc.pathname + loc.search) |
| 135 | await poll_location.until_equals(loc) |
| 136 | |
| 137 | |
| 138 | @pytest.mark.parametrize("hook_name", ["use_request", "use_websocket"]) |
nothing calls this directly
no test coverage detected