@@ -2,6 +2,15 @@ import { render, screen } from '@testing-library/react';
22import { IntlProvider } from 'react-intl' ;
33import PrevNextLink from '..' ;
44
5+ jest . mock ( 'next/router' , ( ) => ( {
6+ useRouter ( ) {
7+ return {
8+ isReady : true ,
9+ asPath : '/link' ,
10+ } ;
11+ } ,
12+ } ) ) ;
13+
514describe ( 'PrevNextLink component' , ( ) => {
615 test ( 'renders nothing if neither previous nor next are provided' , ( ) => {
716 render ( < PrevNextLink /> ) ;
@@ -17,7 +26,7 @@ describe('PrevNextLink component', () => {
1726 </ IntlProvider >
1827 ) ;
1928 const link = screen . getByRole ( 'link' ) ;
20- expect ( link ) . toHaveAttribute ( 'href' , previous . slug ) ;
29+ expect ( link ) . toHaveAttribute ( 'href' , `/en ${ previous . slug } ` ) ;
2130 } ) ;
2231
2332 test ( 'renders next link if next is provided' , ( ) => {
@@ -28,7 +37,7 @@ describe('PrevNextLink component', () => {
2837 </ IntlProvider >
2938 ) ;
3039 const link = screen . getByRole ( 'link' ) ;
31- expect ( link ) . toHaveAttribute ( 'href' , next . slug ) ;
40+ expect ( link ) . toHaveAttribute ( 'href' , `/en ${ next . slug } ` ) ;
3241 } ) ;
3342
3443 test ( 'renders both previous and next links if both are provided' , ( ) => {
@@ -40,7 +49,7 @@ describe('PrevNextLink component', () => {
4049 </ IntlProvider >
4150 ) ;
4251 const links = screen . getAllByRole ( 'link' ) ;
43- expect ( links [ 0 ] ) . toHaveAttribute ( 'href' , previous . slug ) ;
44- expect ( links [ 1 ] ) . toHaveAttribute ( 'href' , next . slug ) ;
52+ expect ( links [ 0 ] ) . toHaveAttribute ( 'href' , `/en ${ previous . slug } ` ) ;
53+ expect ( links [ 1 ] ) . toHaveAttribute ( 'href' , `/en ${ next . slug } ` ) ;
4554 } ) ;
4655} ) ;
0 commit comments