@@ -24,19 +24,19 @@ test('it can navigate to routes', async () => {
24
24
25
25
expect ( screen . queryByText ( / D e t a i l o n e / i) ) . not . toBeInTheDocument ( ) ;
26
26
27
- await navigate ( screen . getByText ( / L o a d o n e / ) ) ;
28
- expect ( screen . queryByText ( / D e t a i l o n e / i) ) . toBeInTheDocument ( ) ;
27
+ await navigate ( screen . getByRole ( 'link' , { name : / l o a d o n e / i } ) ) ;
28
+ expect ( screen . queryByRole ( 'heading' , { name : / D e t a i l o n e / i } ) ) . toBeInTheDocument ( ) ;
29
29
30
- await navigate ( screen . getByText ( / L o a d t h r e e / ) ) ;
31
- expect ( screen . queryByText ( / D e t a i l o n e / i) ) . not . toBeInTheDocument ( ) ;
32
- expect ( screen . queryByText ( / D e t a i l t h r e e / i) ) . toBeInTheDocument ( ) ;
30
+ await navigate ( screen . getByRole ( 'link' , { name : / l o a d t h r e e / i } ) ) ;
31
+ expect ( screen . queryByRole ( 'heading' , { name : / D e t a i l o n e / i } ) ) . not . toBeInTheDocument ( ) ;
32
+ expect ( screen . queryByRole ( 'heading' , { name : / D e t a i l t h r e e / i } ) ) . toBeInTheDocument ( ) ;
33
33
34
- await navigate ( screen . getByText ( / B a c k t o p a r e n t / ) ) ;
35
- expect ( screen . queryByText ( / D e t a i l t h r e e / i) ) . not . toBeInTheDocument ( ) ;
34
+ await navigate ( screen . getByRole ( 'link' , { name : / b a c k t o p a r e n t / i } ) ) ;
35
+ expect ( screen . queryByRole ( 'heading' , { name : / D e t a i l t h r e e / i } ) ) . not . toBeInTheDocument ( ) ;
36
36
37
- await navigate ( screen . getByText ( / L o a d t w o / ) ) ;
38
- expect ( screen . queryByText ( / D e t a i l t w o / i) ) . toBeInTheDocument ( ) ;
39
- await navigate ( screen . getByText ( / h i d d e n x / ) ) ;
37
+ await navigate ( screen . getByRole ( 'link' , { name : / l o a d t w o / i } ) ) ;
38
+ expect ( screen . queryByRole ( 'heading' , { name : / D e t a i l t w o / i } ) ) . toBeInTheDocument ( ) ;
39
+ await navigate ( screen . getByRole ( 'link' , { name : / h i d d e n x / i } ) ) ;
40
40
expect ( screen . queryByText ( / Y o u f o u n d t h e t r e a s u r e ! / i) ) . toBeInTheDocument ( ) ;
41
41
} ) ;
42
42
@@ -61,21 +61,22 @@ test('it can navigate to routes with a base path', async () => {
61
61
] ,
62
62
} ) ;
63
63
64
- expect ( screen . queryByText ( / D e t a i l o n e / i) ) . not . toBeInTheDocument ( ) ;
64
+ expect ( screen . queryByRole ( 'heading' , { name : / D e t a i l o n e / i } ) ) . not . toBeInTheDocument ( ) ;
65
65
66
- await navigate ( screen . getByText ( / L o a d o n e / ) , basePath ) ;
67
- expect ( screen . queryByText ( / D e t a i l o n e / i) ) . toBeInTheDocument ( ) ;
66
+ await navigate ( screen . getByRole ( 'link' , { name : / l o a d o n e / i } ) , basePath ) ;
67
+ expect ( screen . queryByRole ( 'heading' , { name : / D e t a i l o n e / i } ) ) . toBeInTheDocument ( ) ;
68
68
69
- await navigate ( screen . getByText ( / L o a d t h r e e / ) , basePath ) ;
70
- expect ( screen . queryByText ( / D e t a i l o n e / i) ) . not . toBeInTheDocument ( ) ;
71
- expect ( screen . queryByText ( / D e t a i l t h r e e / i) ) . toBeInTheDocument ( ) ;
69
+ await navigate ( screen . getByRole ( 'link' , { name : / l o a d t h r e e / i } ) , basePath ) ;
70
+ expect ( screen . queryByRole ( 'heading' , { name : / D e t a i l o n e / i } ) ) . not . toBeInTheDocument ( ) ;
71
+ expect ( screen . queryByRole ( 'heading' , { name : / D e t a i l t h r e e / i } ) ) . toBeInTheDocument ( ) ;
72
72
73
- await navigate ( screen . getByText ( / B a c k t o p a r e n t / ) ) ;
74
- expect ( screen . queryByText ( / D e t a i l t h r e e / i) ) . not . toBeInTheDocument ( ) ;
73
+ await navigate ( screen . getByRole ( 'link' , { name : / b a c k t o p a r e n t / i } ) ) ;
74
+ expect ( screen . queryByRole ( 'heading' , { name : / D e t a i l t h r e e / i } ) ) . not . toBeInTheDocument ( ) ;
75
75
76
- await navigate ( 'base/detail/two?text=Hello&subtext=World' ) ; // possible to just use strings
77
- expect ( screen . queryByText ( / D e t a i l t w o / i) ) . toBeInTheDocument ( ) ;
78
- expect ( screen . queryByText ( / H e l l o W o r l d / i) ) . toBeInTheDocument ( ) ;
76
+ // It's possible to just use strings
77
+ await navigate ( 'base/detail/two?text=Hello&subtext=World' ) ;
78
+ expect ( screen . queryByRole ( 'heading' , { name : / D e t a i l t w o / i } ) ) . toBeInTheDocument ( ) ;
79
+ expect ( screen . getByText ( / H e l l o W o r l d / i) ) . toBeInTheDocument ( ) ;
79
80
80
81
await navigate ( '/hidden-detail' , basePath ) ;
81
82
expect ( screen . queryByText ( / Y o u f o u n d t h e t r e a s u r e ! / i) ) . toBeInTheDocument ( ) ;
0 commit comments