@@ -186,37 +186,41 @@ describe('format', () => {
186
186
expect ( formattedStr ) . toEqual ( 'en-XZ cuerda!' ) ;
187
187
} ) ;
188
188
189
- it ( 'overwrites existing locale strings' , async ( ) => {
190
- const filename = `${ LH_ROOT } /core/audits/is-on-https.js` ;
191
- const { UIStrings} = await import ( '../../../core/audits/is-on-https.js' ) ;
192
- const str_ = i18n . createIcuMessageFn ( filename , UIStrings ) ;
193
-
194
- // To start with, we get back the intended string..
195
- const origTitle = format . getFormatted ( str_ ( UIStrings . title ) , 'es-419' ) ;
196
- expect ( origTitle ) . toEqual ( 'Usa HTTPS' ) ;
197
- const origFailureTitle = format . getFormatted ( str_ ( UIStrings . failureTitle ) , 'es-419' ) ;
198
- expect ( origFailureTitle ) . toEqual ( 'No usa HTTPS' ) ;
199
-
200
- // Now we declare and register the new string...
201
- const localeData = {
202
- 'core/audits/is-on-https.js | title' : {
203
- 'message' : 'new string for es-419 uses https!' ,
204
- } ,
205
- } ;
206
- format . registerLocaleData ( 'es-419' , localeData ) ;
207
-
208
- // And confirm that's what is returned
209
- const newTitle = format . getFormatted ( str_ ( UIStrings . title ) , 'es-419' ) ;
210
- expect ( newTitle ) . toEqual ( 'new string for es-419 uses https!' ) ;
211
-
212
- // Meanwhile another string that wasn't set in registerLocaleData just falls back to english
213
- const newFailureTitle = format . getFormatted ( str_ ( UIStrings . failureTitle ) , 'es-419' ) ;
214
- expect ( newFailureTitle ) . toEqual ( 'Does not use HTTPS' ) ;
215
-
216
- // Restore overwritten strings to avoid messing with other tests
217
- locales [ 'es-419' ] = clonedLocales [ 'es-419' ] ;
218
- const title = format . getFormatted ( str_ ( UIStrings . title ) , 'es-419' ) ;
219
- expect ( title ) . toEqual ( 'Usa HTTPS' ) ;
189
+ [
190
+ { label : 'relative path' , filename : 'core/audits/is-on-https.js' } ,
191
+ { label : 'absolute path' , filename : `${ LH_ROOT } /core/audits/is-on-https.js` } ,
192
+ ] . forEach ( ( { label, filename} ) => {
193
+ it ( `overwrites existing locale strings: ${ label } ` , async ( ) => {
194
+ const { UIStrings} = await import ( '../../../core/audits/is-on-https.js' ) ;
195
+ const str_ = i18n . createIcuMessageFn ( filename , UIStrings ) ;
196
+
197
+ // To start with, we get back the intended string..
198
+ const origTitle = format . getFormatted ( str_ ( UIStrings . title ) , 'es-419' ) ;
199
+ expect ( origTitle ) . toEqual ( 'Usa HTTPS' ) ;
200
+ const origFailureTitle = format . getFormatted ( str_ ( UIStrings . failureTitle ) , 'es-419' ) ;
201
+ expect ( origFailureTitle ) . toEqual ( 'No usa HTTPS' ) ;
202
+
203
+ // Now we declare and register the new string...
204
+ const localeData = {
205
+ 'core/audits/is-on-https.js | title' : {
206
+ 'message' : 'new string for es-419 uses https!' ,
207
+ } ,
208
+ } ;
209
+ format . registerLocaleData ( 'es-419' , localeData ) ;
210
+
211
+ // And confirm that's what is returned
212
+ const newTitle = format . getFormatted ( str_ ( UIStrings . title ) , 'es-419' ) ;
213
+ expect ( newTitle ) . toEqual ( 'new string for es-419 uses https!' ) ;
214
+
215
+ // Meanwhile another string that wasn't set in registerLocaleData just falls back to english
216
+ const newFailureTitle = format . getFormatted ( str_ ( UIStrings . failureTitle ) , 'es-419' ) ;
217
+ expect ( newFailureTitle ) . toEqual ( 'Does not use HTTPS' ) ;
218
+
219
+ // Restore overwritten strings to avoid messing with other tests
220
+ locales [ 'es-419' ] = clonedLocales [ 'es-419' ] ;
221
+ const title = format . getFormatted ( str_ ( UIStrings . title ) , 'es-419' ) ;
222
+ expect ( title ) . toEqual ( 'Usa HTTPS' ) ;
223
+ } ) ;
220
224
} ) ;
221
225
} ) ;
222
226
0 commit comments