@@ -156,6 +156,21 @@ describe('<FormattedMessage>', () => {
156156 expect ( rendered . text ( ) ) . toBe ( intl . formatMessage ( descriptor ) ) ;
157157 } ) ;
158158
159+ it ( 'should render out raw array if tagName is not specified' , ( ) => {
160+ const descriptor = {
161+ id : 'hello' ,
162+ defaultMessage : 'Hello, World!' ,
163+ tagName : ''
164+ } ;
165+
166+ const rendered = mountWithProvider (
167+ descriptor ,
168+ { ...providerProps , textComponent : undefined }
169+ ) ;
170+
171+ expect ( rendered . text ( ) ) . toBe ( intl . formatMessage ( descriptor ) ) ;
172+ } ) ;
173+
159174 it ( 'supports function-as-child pattern' , ( ) => {
160175 const descriptor = {
161176 id : 'hello' ,
@@ -244,6 +259,44 @@ describe('<FormattedMessage>', () => {
244259 expect ( nameNode . text ( ) ) . toBe ( 'Jest' ) ;
245260 } ) ;
246261 } ) ;
262+ it ( 'should use timeZone from Provider' , function ( ) {
263+ const rendered = mountWithProvider (
264+ {
265+ id : 'hello' ,
266+ values : {
267+ ts : new Date ( 0 ) ,
268+ } ,
269+ } ,
270+ {
271+ ...providerProps ,
272+ messages : {
273+ hello : 'Hello, {ts, date, short} - {ts, time, short}' ,
274+ } ,
275+ timeZone : 'Asia/Tokyo' ,
276+ }
277+ ) ;
278+
279+ expect ( rendered . text ( ) ) . toBe ( 'Hello, 1/1/70 - 9:00 AM' ) ;
280+ } ) ;
281+
282+ it ( 'should use timeZone from Provider for defaultMessage' , function ( ) {
283+ const rendered = mountWithProvider (
284+ {
285+ id : 'hello' ,
286+ defaultMessage : 'Hello, {ts, date, short} - {ts, time, short}' ,
287+ values : {
288+ ts : new Date ( 0 ) ,
289+ } ,
290+ } ,
291+ {
292+ ...providerProps ,
293+ timeZone : 'Asia/Tokyo' ,
294+ }
295+ ) ;
296+
297+ expect ( rendered . text ( ) ) . toBe ( 'Hello, 1/1/70 - 9:00 AM' ) ;
298+ } ) ;
299+
247300 it ( 'should merge timeZone into formats' , function ( ) {
248301 const rendered = mountWithProvider (
249302 {
@@ -259,18 +312,20 @@ describe('<FormattedMessage>', () => {
259312 } ,
260313 formats : {
261314 time : {
262- short : { hour : 'numeric' , minute : 'numeric' , second : 'numeric' } ,
263- } ,
264- date : { short : { year : '2-digit' , month : 'numeric' , day : 'numeric' } } ,
265- } as CustomFormats ,
266- timeZone : 'Europe/London' ,
315+ short : {
316+ second : 'numeric' ,
317+ timeZoneName : 'long'
318+ }
319+ }
320+ } ,
321+ timeZone : 'Asia/Tokyo' ,
267322 }
268323 ) ;
269324
270- expect ( rendered . text ( ) ) . toBe ( 'Hello, 1/1/70 - 1 :00:00 AM' ) ;
325+ expect ( rendered . text ( ) ) . toBe ( 'Hello, 1/1/70 - 9 :00:00 AM Japan Standard Time ' ) ;
271326 } ) ;
272327
273- it ( 'should merge timeZone into formats ' , function ( ) {
328+ it ( 'should merge timeZone into defaultFormats ' , function ( ) {
274329 const rendered = mountWithProvider (
275330 {
276331 id : 'hello' ,
@@ -283,15 +338,17 @@ describe('<FormattedMessage>', () => {
283338 ...providerProps ,
284339 defaultFormats : {
285340 time : {
286- short : { hour : 'numeric' , minute : 'numeric' , second : 'numeric' } ,
287- } ,
288- date : { short : { year : '2-digit' , month : 'numeric' , day : 'numeric' } } ,
289- } as CustomFormats ,
341+ short : {
342+ second : 'numeric' ,
343+ timeZoneName : 'long'
344+ }
345+ }
346+ } ,
290347 timeZone : 'Asia/Tokyo' ,
291348 }
292349 ) ;
293350
294- expect ( rendered . text ( ) ) . toBe ( 'Hello, 1/1/70 - 9:00:00 AM' ) ;
351+ expect ( rendered . text ( ) ) . toBe ( 'Hello, 1/1/70 - 9:00:00 AM Japan Standard Time ' ) ;
295352 } ) ;
296353
297354 it ( 'should re-render when `values` are different' , ( ) => {
0 commit comments