@@ -108,6 +108,7 @@ describe('lib', () => {
108108 jest . clearAllMocks ( ) ;
109109 } ) ;
110110
111+ // test 1: should replace {locale} token when locale is provided and not default
111112 test ( 'should replace {locale} token when locale is provided and not default' , async ( ) => {
112113 global . fetch . mockResolvedValueOnce ( {
113114 text : ( ) => Promise . resolve ( mockTemplateHtml )
@@ -119,9 +120,10 @@ describe('lib', () => {
119120
120121 await prepareBaseTemplate ( url , blocks , context ) ;
121122
122- expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/en/products/default.plain.html' ) ;
123+ expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/en/products/default.plain.html' , { } ) ;
123124 } ) ;
124125
126+ // test 2: should replace {locale} token with complex locale codes
125127 test ( 'should replace {locale} token with complex locale codes' , async ( ) => {
126128 global . fetch . mockResolvedValueOnce ( {
127129 text : ( ) => Promise . resolve ( mockTemplateHtml )
@@ -133,7 +135,7 @@ describe('lib', () => {
133135
134136 await prepareBaseTemplate ( url , blocks , context ) ;
135137
136- expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/en/uk/products/default.plain.html' ) ;
138+ expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/en/uk/products/default.plain.html' , { } ) ;
137139 } ) ;
138140
139141 test ( 'should handle URL with multiple {locale} tokens (only replaces first occurrence)' , async ( ) => {
@@ -148,7 +150,7 @@ describe('lib', () => {
148150 await prepareBaseTemplate ( url , blocks , context ) ;
149151
150152 // Current implementation only replaces the first {locale} occurrence
151- expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/fr/category/{locale}/products/default.plain.html' ) ;
153+ expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/fr/category/{locale}/products/default.plain.html' , { } ) ;
152154 } ) ;
153155
154156 test ( 'should trim whitespace and trailing slash before locale replacement' , async ( ) => {
@@ -162,7 +164,7 @@ describe('lib', () => {
162164
163165 await prepareBaseTemplate ( url , blocks , context ) ;
164166
165- expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/de/products/default.plain.html' ) ;
167+ expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/de/products/default.plain.html' , { } ) ;
166168 } ) ;
167169
168170 test ( 'should not replace {locale} token when locale is "default"' , async ( ) => {
@@ -176,7 +178,7 @@ describe('lib', () => {
176178
177179 await prepareBaseTemplate ( url , blocks , context ) ;
178180
179- expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/{locale}/products/default.plain.html' ) ;
181+ expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/{locale}/products/default.plain.html' , { } ) ;
180182 } ) ;
181183
182184 test ( 'should not replace {locale} token when locale is not provided' , async ( ) => {
@@ -190,7 +192,7 @@ describe('lib', () => {
190192
191193 await prepareBaseTemplate ( url , blocks , context ) ;
192194
193- expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/{locale}/products/default.plain.html' ) ;
195+ expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/{locale}/products/default.plain.html' , { } ) ;
194196 } ) ;
195197
196198 test ( 'should not replace {locale} token when locale is null' , async ( ) => {
@@ -204,7 +206,7 @@ describe('lib', () => {
204206
205207 await prepareBaseTemplate ( url , blocks , context ) ;
206208
207- expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/{locale}/products/default.plain.html' ) ;
209+ expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/{locale}/products/default.plain.html' , { } ) ;
208210 } ) ;
209211
210212 test ( 'should not replace {locale} token when locale is undefined' , async ( ) => {
@@ -218,7 +220,7 @@ describe('lib', () => {
218220
219221 await prepareBaseTemplate ( url , blocks , context ) ;
220222
221- expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/{locale}/products/default.plain.html' ) ;
223+ expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/{locale}/products/default.plain.html' , { } ) ;
222224 } ) ;
223225
224226 test ( 'should replace blocks with handlebars partials after locale replacement' , async ( ) => {
@@ -232,7 +234,7 @@ describe('lib', () => {
232234
233235 const result = await prepareBaseTemplate ( url , blocks , context ) ;
234236
235- expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/es/products/default.plain.html' ) ;
237+ expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/es/products/default.plain.html' , { } ) ;
236238 expect ( result ) . toContain ( '{{> hero }}' ) ;
237239 expect ( result ) . toContain ( '{{> product-recommendations }}' ) ;
238240 } ) ;
@@ -248,7 +250,7 @@ describe('lib', () => {
248250
249251 await prepareBaseTemplate ( url , blocks , context ) ;
250252
251- expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/products/default.plain.html' ) ;
253+ expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/products/default.plain.html' , { } ) ;
252254 } ) ;
253255
254256 test ( 'should handle empty blocks array' , async ( ) => {
@@ -262,7 +264,7 @@ describe('lib', () => {
262264
263265 const result = await prepareBaseTemplate ( url , blocks , context ) ;
264266
265- expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/it/products/default.plain.html' ) ;
267+ expect ( global . fetch ) . toHaveBeenCalledWith ( 'https://content.com/it/products/default.plain.html' , { } ) ;
266268 expect ( result ) . toBe ( '<div class="hero">Hero content</div><div class="product-recommendations">Recommendations</div>\n' ) ;
267269 } ) ;
268270
0 commit comments