1
+ import * as cheerio from 'cheerio' ;
1
2
import * as assert from 'node:assert/strict' ;
2
3
import { after , afterEach , before , describe , it } from 'node:test' ;
3
- import * as cheerio from 'cheerio' ;
4
4
import testAdapter from './test-adapter.js' ;
5
5
import { loadFixture } from './test-utils.js' ;
6
6
@@ -2000,12 +2000,14 @@ describe('Fallback rewrite dev server', () => {
2000
2000
root : './fixtures/i18n-routing-fallback/' ,
2001
2001
i18n : {
2002
2002
defaultLocale : 'en' ,
2003
- locales : [ 'en' , 'fr' ] ,
2003
+ locales : [ 'en' , 'fr' , 'es' , 'it' , 'pt' ] ,
2004
2004
routing : {
2005
2005
prefixDefaultLocale : false ,
2006
2006
} ,
2007
2007
fallback : {
2008
2008
fr : 'en' ,
2009
+ it : 'en' ,
2010
+ es : 'pt' ,
2009
2011
} ,
2010
2012
fallbackType : 'rewrite' ,
2011
2013
} ,
@@ -2021,6 +2023,27 @@ describe('Fallback rewrite dev server', () => {
2021
2023
assert . match ( html , / H e l l o / ) ;
2022
2024
// assert.fail()
2023
2025
} ) ;
2026
+
2027
+ it ( 'should render fallback locale paths with path parameters correctly (fr)' , async ( ) => {
2028
+ let response = await fixture . fetch ( '/fr/blog/1' ) ;
2029
+ assert . equal ( response . status , 200 ) ;
2030
+ const text = await response . text ( ) ;
2031
+ assert . match ( text , / H e l l o w o r l d / ) ;
2032
+ } ) ;
2033
+
2034
+ it ( 'should render fallback locale paths with path parameters correctly (es)' , async ( ) => {
2035
+ let response = await fixture . fetch ( '/es/blog/1' ) ;
2036
+ assert . equal ( response . status , 200 ) ;
2037
+ const text = await response . text ( ) ;
2038
+ assert . match ( text , / H o l a m u n d o / ) ;
2039
+ } ) ;
2040
+
2041
+ it ( 'should render fallback locale paths with query parameters correctly (it)' , async ( ) => {
2042
+ let response = await fixture . fetch ( '/it/blog/1' ) ;
2043
+ assert . equal ( response . status , 200 ) ;
2044
+ const text = await response . text ( ) ;
2045
+ assert . match ( text , / H e l l o w o r l d / ) ;
2046
+ } ) ;
2024
2047
} ) ;
2025
2048
2026
2049
describe ( 'Fallback rewrite SSG' , ( ) => {
@@ -2032,13 +2055,15 @@ describe('Fallback rewrite SSG', () => {
2032
2055
root : './fixtures/i18n-routing-fallback/' ,
2033
2056
i18n : {
2034
2057
defaultLocale : 'en' ,
2035
- locales : [ 'en' , 'fr' ] ,
2058
+ locales : [ 'en' , 'fr' , 'es' , 'it' , 'pt' ] ,
2036
2059
routing : {
2037
2060
prefixDefaultLocale : false ,
2038
2061
fallbackType : 'rewrite' ,
2039
2062
} ,
2040
2063
fallback : {
2041
2064
fr : 'en' ,
2065
+ it : 'en' ,
2066
+ es : 'pt' ,
2042
2067
} ,
2043
2068
} ,
2044
2069
} ) ;
@@ -2051,6 +2076,21 @@ describe('Fallback rewrite SSG', () => {
2051
2076
assert . match ( html , / H e l l o / ) ;
2052
2077
// assert.fail()
2053
2078
} ) ;
2079
+
2080
+ it ( 'should render fallback locale paths with path parameters correctly (fr)' , async ( ) => {
2081
+ const html = await fixture . readFile ( '/fr/blog/1/index.html' ) ;
2082
+ assert . match ( html , / H e l l o w o r l d / ) ;
2083
+ } ) ;
2084
+
2085
+ it ( 'should render fallback locale paths with path parameters correctly (es)' , async ( ) => {
2086
+ const html = await fixture . readFile ( '/es/blog/1/index.html' ) ;
2087
+ assert . match ( html , / H o l a m u n d o / ) ;
2088
+ } ) ;
2089
+
2090
+ it ( 'should render fallback locale paths with query parameters correctly (it)' , async ( ) => {
2091
+ const html = await fixture . readFile ( '/it/blog/1/index.html' ) ;
2092
+ assert . match ( html , / H e l l o w o r l d / ) ;
2093
+ } ) ;
2054
2094
} ) ;
2055
2095
2056
2096
describe ( 'Fallback rewrite SSR' , ( ) => {
@@ -2066,13 +2106,15 @@ describe('Fallback rewrite SSR', () => {
2066
2106
adapter : testAdapter ( ) ,
2067
2107
i18n : {
2068
2108
defaultLocale : 'en' ,
2069
- locales : [ 'en' , 'fr' ] ,
2109
+ locales : [ 'en' , 'fr' , 'es' , 'it' , 'pt' ] ,
2070
2110
routing : {
2071
2111
prefixDefaultLocale : false ,
2072
2112
fallbackType : 'rewrite' ,
2073
2113
} ,
2074
2114
fallback : {
2075
2115
fr : 'en' ,
2116
+ it : 'en' ,
2117
+ es : 'pt' ,
2076
2118
} ,
2077
2119
} ,
2078
2120
} ) ;
@@ -2087,4 +2129,28 @@ describe('Fallback rewrite SSR', () => {
2087
2129
const html = await response . text ( ) ;
2088
2130
assert . match ( html , / H e l l o / ) ;
2089
2131
} ) ;
2132
+
2133
+ it ( 'should render fallback locale paths with path parameters correctly (fr)' , async ( ) => {
2134
+ let request = new Request ( 'http://example.com/new-site/fr/blog/1' ) ;
2135
+ let response = await app . render ( request ) ;
2136
+ assert . equal ( response . status , 200 ) ;
2137
+ const text = await response . text ( ) ;
2138
+ assert . match ( text , / H e l l o w o r l d / ) ;
2139
+ } ) ;
2140
+
2141
+ it ( 'should render fallback locale paths with path parameters correctly (es)' , async ( ) => {
2142
+ let request = new Request ( 'http://example.com/new-site/es/blog/1' ) ;
2143
+ let response = await app . render ( request ) ;
2144
+ assert . equal ( response . status , 200 ) ;
2145
+ const text = await response . text ( ) ;
2146
+ assert . match ( text , / H o l a m u n d o / ) ;
2147
+ } ) ;
2148
+
2149
+ it ( 'should render fallback locale paths with query parameters correctly (it)' , async ( ) => {
2150
+ let request = new Request ( 'http://example.com/new-site/it/blog/1' ) ;
2151
+ let response = await app . render ( request ) ;
2152
+ assert . equal ( response . status , 200 ) ;
2153
+ const text = await response . text ( ) ;
2154
+ assert . match ( text , / H e l l o w o r l d / ) ;
2155
+ } ) ;
2090
2156
} ) ;
0 commit comments