@@ -19,6 +19,9 @@ describe("AdminNavigation", () => {
1919 it ( "renders all admin links" , ( ) => {
2020 render ( < AdminNavigation /> ) ;
2121 expect ( screen . getByRole ( "link" , { name : "Accueil" } ) ) . toBeInTheDocument ( ) ;
22+ expect (
23+ screen . getByRole ( "link" , { name : "Déclarations" } ) ,
24+ ) . toBeInTheDocument ( ) ;
2225 expect (
2326 screen . getByRole ( "link" , { name : "Mimoquer un Siren" } ) ,
2427 ) . toBeInTheDocument ( ) ;
@@ -61,4 +64,28 @@ describe("AdminNavigation", () => {
6164 "aria-current" ,
6265 ) ;
6366 } ) ;
67+
68+ it ( "marks /admin/declarations as active — and not Accueil" , ( ) => {
69+ ( usePathname as Mock ) . mockReturnValue ( "/admin/declarations" ) ;
70+ render ( < AdminNavigation /> ) ;
71+ expect ( screen . getByRole ( "link" , { name : "Déclarations" } ) ) . toHaveAttribute (
72+ "aria-current" ,
73+ "page" ,
74+ ) ;
75+ expect ( screen . getByRole ( "link" , { name : "Accueil" } ) ) . not . toHaveAttribute (
76+ "aria-current" ,
77+ ) ;
78+ } ) ;
79+
80+ it ( "marks /admin/declarations/<id> as active on the Déclarations link" , ( ) => {
81+ ( usePathname as Mock ) . mockReturnValue ( "/admin/declarations/abc123" ) ;
82+ render ( < AdminNavigation /> ) ;
83+ expect ( screen . getByRole ( "link" , { name : "Déclarations" } ) ) . toHaveAttribute (
84+ "aria-current" ,
85+ "page" ,
86+ ) ;
87+ expect ( screen . getByRole ( "link" , { name : "Accueil" } ) ) . not . toHaveAttribute (
88+ "aria-current" ,
89+ ) ;
90+ } ) ;
6491} ) ;
0 commit comments