4
4
5
5
from idom_router import (
6
6
Route ,
7
- RoutesConstructor ,
8
- configure ,
7
+ RouterConstructor ,
8
+ create_router ,
9
9
link ,
10
10
use_location ,
11
11
use_params ,
14
14
15
15
16
16
@pytest .fixture
17
- def routes (backend : BackendFixture ):
18
- return configure (backend .implementation )
17
+ def router (backend : BackendFixture ):
18
+ return create_router (backend .implementation )
19
19
20
20
21
- def test_configure (backend ):
22
- configure (backend .implementation )
23
- configure (backend .implementation .use_location )
21
+ def test_create_router (backend ):
22
+ create_router (backend .implementation )
23
+ create_router (backend .implementation .use_location )
24
24
with pytest .raises (
25
25
TypeError , match = "Expected a 'BackendImplementation' or 'use_location' hook"
26
26
):
27
- configure (None )
27
+ create_router (None )
28
28
29
29
30
- async def test_simple_router (display : DisplayFixture , routes : RoutesConstructor ):
30
+ async def test_simple_router (display : DisplayFixture , router : RouterConstructor ):
31
31
def make_location_check (path , * routes ):
32
32
name = path .lstrip ("/" ).replace ("/" , "-" )
33
33
@@ -40,7 +40,7 @@ def check_location():
40
40
41
41
@component
42
42
def sample ():
43
- return routes (
43
+ return router (
44
44
make_location_check ("/a" ),
45
45
make_location_check ("/b" ),
46
46
make_location_check ("/c" ),
@@ -68,10 +68,10 @@ def sample():
68
68
assert not await root_element .inner_html ()
69
69
70
70
71
- async def test_nested_routes (display : DisplayFixture , routes : RoutesConstructor ):
71
+ async def test_nested_routes (display : DisplayFixture , router : RouterConstructor ):
72
72
@component
73
73
def sample ():
74
- return routes (
74
+ return router (
75
75
Route (
76
76
"/a" ,
77
77
html .h1 ({"id" : "a" }, "A" ),
@@ -94,13 +94,13 @@ def sample():
94
94
await display .page .wait_for_selector (selector )
95
95
96
96
97
- async def test_navigate_with_link (display : DisplayFixture , routes : RoutesConstructor ):
97
+ async def test_navigate_with_link (display : DisplayFixture , router : RouterConstructor ):
98
98
render_count = Ref (0 )
99
99
100
100
@component
101
101
def sample ():
102
102
render_count .current += 1
103
- return routes (
103
+ return router (
104
104
Route ("/" , link ({"id" : "root" }, "Root" , to = "/a" )),
105
105
Route ("/a" , link ({"id" : "a" }, "A" , to = "/b" )),
106
106
Route ("/b" , link ({"id" : "b" }, "B" , to = "/c" )),
@@ -121,7 +121,7 @@ def sample():
121
121
assert render_count .current == 1
122
122
123
123
124
- async def test_use_params (display : DisplayFixture , routes : RoutesConstructor ):
124
+ async def test_use_params (display : DisplayFixture , router : RouterConstructor ):
125
125
expected_params = {}
126
126
127
127
@component
@@ -131,7 +131,7 @@ def check_params():
131
131
132
132
@component
133
133
def sample ():
134
- return routes (
134
+ return router (
135
135
Route (
136
136
"/first/{first:str}" ,
137
137
check_params (),
@@ -157,7 +157,7 @@ def sample():
157
157
await display .page .wait_for_selector ("#success" )
158
158
159
159
160
- async def test_use_query (display : DisplayFixture , routes : RoutesConstructor ):
160
+ async def test_use_query (display : DisplayFixture , router : RouterConstructor ):
161
161
expected_query = {}
162
162
163
163
@component
@@ -167,7 +167,7 @@ def check_query():
167
167
168
168
@component
169
169
def sample ():
170
- return routes (Route ("/" , check_query ()))
170
+ return router (Route ("/" , check_query ()))
171
171
172
172
await display .show (sample )
173
173
0 commit comments