@@ -924,6 +924,15 @@ describe.each([
924
924
) ;
925
925
expect ( markup ) . toContain ( 'href="/de/about"' ) ;
926
926
} ) ;
927
+
928
+ it ( 'accepts search params' , ( ) => {
929
+ render (
930
+ < Link href = { { pathname : '/about' , query : { foo : 'bar' } } } > Test</ Link >
931
+ ) ;
932
+ expect (
933
+ screen . getByRole ( 'link' , { name : 'Test' } ) . getAttribute ( 'href' )
934
+ ) . toBe ( '/about?foo=bar' ) ;
935
+ } ) ;
927
936
} ) ;
928
937
929
938
describe ( 'getPathname' , ( ) => {
@@ -978,6 +987,39 @@ describe.each([
978
987
} ) ;
979
988
} ) ;
980
989
990
+ describe ( "localePrefix: 'as-needed', with `domains` and `pathnames`" , ( ) => {
991
+ const { Link, permanentRedirect, redirect} = createNavigation ( {
992
+ locales,
993
+ defaultLocale,
994
+ domains,
995
+ localePrefix : 'as-needed' ,
996
+ pathnames
997
+ } ) ;
998
+
999
+ describe ( 'Link' , ( ) => {
1000
+ it ( 'accepts search params' , ( ) => {
1001
+ render (
1002
+ < Link href = { { pathname : '/about' , query : { foo : 'bar' } } } > Test</ Link >
1003
+ ) ;
1004
+ expect (
1005
+ screen . getByRole ( 'link' , { name : 'Test' } ) . getAttribute ( 'href' )
1006
+ ) . toBe ( '/about?foo=bar' ) ;
1007
+ } ) ;
1008
+ } ) ;
1009
+
1010
+ describe . each ( [
1011
+ [ 'redirect' , redirect , nextRedirect ] ,
1012
+ [ 'permanentRedirect' , permanentRedirect , nextPermanentRedirect ]
1013
+ ] ) ( '%s' , ( _ , redirectFn , nextRedirectFn ) => {
1014
+ it ( 'accepts search params' , ( ) => {
1015
+ runInRender ( ( ) =>
1016
+ redirectFn ( { href : { pathname : '/' , query : { foo : 'bar' } } , locale : 'en' } )
1017
+ ) ;
1018
+ expect ( nextRedirectFn ) . toHaveBeenLastCalledWith ( '/en?foo=bar' ) ;
1019
+ } ) ;
1020
+ } ) ;
1021
+ } ) ;
1022
+
981
1023
describe ( "localePrefix: 'never'" , ( ) => {
982
1024
const { Link, getPathname, permanentRedirect, redirect} = createNavigation ( {
983
1025
locales,
0 commit comments