@@ -263,6 +263,134 @@ foo = { $arg }
263
263
assert . deepEqual ( args [ 1 ] , { arg : 'ARG' } ) ;
264
264
} ) ;
265
265
266
+ test ( 'render with a fragment and no message preserves the fragment' ,
267
+ function ( ) {
268
+ const mcx = new FluentBundle ( ) ;
269
+ const l10n = new ReactLocalization ( [ mcx ] ) ;
270
+
271
+ const wrapper = shallow (
272
+ < Localized id = "foo" >
273
+ < React . Fragment >
274
+ < div > Fragment content</ div >
275
+ </ React . Fragment >
276
+ </ Localized > ,
277
+ { context : { l10n } }
278
+ ) ;
279
+
280
+ assert . ok ( wrapper . equals (
281
+ < React . Fragment >
282
+ < div > Fragment content</ div >
283
+ </ React . Fragment >
284
+ ) ) ;
285
+ } ) ;
286
+
287
+ test ( 'render with a fragment and no message value preserves the fragment' ,
288
+ function ( ) {
289
+ const mcx = new FluentBundle ( ) ;
290
+ const l10n = new ReactLocalization ( [ mcx ] ) ;
291
+ mcx . addMessages ( `
292
+ foo =
293
+ .attr = Attribute
294
+ ` )
295
+
296
+ const wrapper = shallow (
297
+ < Localized id = "foo" >
298
+ < React . Fragment >
299
+ < div > Fragment content</ div >
300
+ </ React . Fragment >
301
+ </ Localized > ,
302
+ { context : { l10n } }
303
+ ) ;
304
+
305
+ assert . ok ( wrapper . equals (
306
+ < React . Fragment >
307
+ < div > Fragment content</ div >
308
+ </ React . Fragment >
309
+ ) ) ;
310
+ } ) ;
311
+
312
+ test ( 'render with a fragment renders the message into the fragment' , function ( ) {
313
+ const mcx = new FluentBundle ( ) ;
314
+ const l10n = new ReactLocalization ( [ mcx ] ) ;
315
+ mcx . addMessages ( `
316
+ foo = Test message
317
+ ` )
318
+
319
+ const wrapper = shallow (
320
+ < Localized id = "foo" >
321
+ < React . Fragment >
322
+ < div > Fragment content</ div >
323
+ </ React . Fragment >
324
+ </ Localized > ,
325
+ { context : { l10n } }
326
+ ) ;
327
+
328
+ assert . ok ( wrapper . equals (
329
+ < React . Fragment >
330
+ Test message
331
+ </ React . Fragment >
332
+ ) ) ;
333
+ } ) ;
334
+
335
+ test ( 'render with an empty fragment and no message preserves the fragment' ,
336
+ function ( ) {
337
+ const mcx = new FluentBundle ( ) ;
338
+ const l10n = new ReactLocalization ( [ mcx ] ) ;
339
+
340
+ const wrapper = shallow (
341
+ < Localized id = "foo" >
342
+ < React . Fragment />
343
+ </ Localized > ,
344
+ { context : { l10n } }
345
+ ) ;
346
+
347
+ assert . ok ( wrapper . equals (
348
+ < React . Fragment />
349
+ ) ) ;
350
+ } ) ;
351
+
352
+ test ( 'render with an empty fragment and no message value preserves the fragment' ,
353
+ function ( ) {
354
+ const mcx = new FluentBundle ( ) ;
355
+ const l10n = new ReactLocalization ( [ mcx ] ) ;
356
+ mcx . addMessages ( `
357
+ foo =
358
+ .attr = Attribute
359
+ ` )
360
+
361
+ const wrapper = shallow (
362
+ < Localized id = "foo" >
363
+ < React . Fragment />
364
+ </ Localized > ,
365
+ { context : { l10n } }
366
+ ) ;
367
+
368
+ assert . ok ( wrapper . equals (
369
+ < React . Fragment />
370
+ ) ) ;
371
+ } ) ;
372
+
373
+ test ( 'render with an empty fragment renders the message into the fragment' , function ( ) {
374
+ const mcx = new FluentBundle ( ) ;
375
+ const l10n = new ReactLocalization ( [ mcx ] ) ;
376
+ mcx . addMessages ( `
377
+ foo = Test message
378
+ ` )
379
+
380
+ const wrapper = shallow (
381
+ < Localized id = "foo" >
382
+ < React . Fragment />
383
+ </ Localized > ,
384
+ { context : { l10n } }
385
+ ) ;
386
+
387
+ assert . ok ( wrapper . equals (
388
+ < React . Fragment >
389
+ Test message
390
+ </ React . Fragment >
391
+ ) ) ;
392
+ } ) ;
393
+
266
394
test ( 'render with a string fallback and no message returns the fallback' ,
267
395
function ( ) {
268
396
const mcx = new FluentBundle ( ) ;
0 commit comments