44 Link ,
55 BrowserRouter ,
66 useLocation ,
7- Switch ,
7+ Routes ,
88 Route ,
99} from "react-router-dom" ;
1010import { mocked } from "ts-jest/utils" ;
@@ -498,6 +498,18 @@ describe("Layout", () => {
498498
499499 describe ( "navigation behavior" , ( ) => {
500500 it ( "should work with react-router" , ( ) => {
501+ function Route2 ( ) : ReactElement {
502+ return (
503+ < >
504+ < h1 > Route 2</ h1 >
505+ < Routes >
506+ < Route path = "1" element = { < h2 > Route 2-1</ h2 > } />
507+ < Route path = "2" element = { < h2 > Route 2-2</ h2 > } />
508+ < Route path = "3" element = { < h2 > Route 2-3</ h2 > } />
509+ </ Routes >
510+ </ >
511+ ) ;
512+ }
501513 function Test ( ) : ReactElement {
502514 const { pathname } = useLocation ( ) ;
503515 return (
@@ -508,34 +520,13 @@ describe("Layout", () => {
508520 Link
509521 ) }
510522 >
511- < Switch >
512- < Route path = "/" exact >
513- < h1 > Home</ h1 >
514- </ Route >
515- < Route path = "/route-1" >
516- < h1 > Route 1</ h1 >
517- </ Route >
518- < Route path = "/route-2" >
519- < h1 > Route 2</ h1 >
520- < Switch >
521- < Route path = "/route-2/1" >
522- < h2 > Route 2-1</ h2 >
523- </ Route >
524- < Route path = "/route-2/2" >
525- < h2 > Route 2-2</ h2 >
526- </ Route >
527- < Route path = "/route-2/3" >
528- < h2 > Route 2-3</ h2 >
529- </ Route >
530- </ Switch >
531- </ Route >
532- < Route path = "/route-3" >
533- < h1 > Route 3</ h1 >
534- </ Route >
535- < Route path = "/route-4" >
536- < h1 > Route 4</ h1 >
537- </ Route >
538- </ Switch >
523+ < Routes >
524+ < Route path = "/" element = { < h1 > Home</ h1 > } />
525+ < Route path = "route-1" element = { < h1 > Route 1</ h1 > } />
526+ < Route path = "route-2/*" element = { < Route2 /> } />
527+ < Route path = "route-3" element = { < h1 > Route 3</ h1 > } />
528+ < Route path = "route-4" element = { < h1 > Route 4</ h1 > } />
529+ </ Routes >
539530 </ Layout >
540531 ) ;
541532 }
0 commit comments