@@ -156,19 +156,6 @@ describe('Datetime', () => {
156156 expect ( utils . isOpen ( component ) ) . toBeTruthy ( ) ;
157157 } ) ;
158158
159- it ( 'dateFormat -> prop changes and value updates accordingly' , ( ) => {
160- const date = new Date ( 2000 , 0 , 15 , 2 , 2 , 2 , 2 ) ,
161- component = utils . createDatetime ( {
162- dateFormat : 'YYYY-MM-DD' , timeFormat : false , defaultValue : date
163- } ) ;
164-
165- const valueBefore = utils . getInputValue ( component ) ;
166- component . setProps ( { dateFormat : 'DD.MM.YYYY' } ) ;
167- const valueAfter = utils . getInputValue ( component ) ;
168-
169- expect ( valueBefore ) . not . toEqual ( valueAfter ) ;
170- } ) ;
171-
172159 describe ( 'with custom props' , ( ) => {
173160 it ( 'input=false' , ( ) => {
174161 const component = utils . createDatetime ( { input : false } ) ;
@@ -642,6 +629,71 @@ describe('Datetime', () => {
642629 expect ( component . find ( '.rdtCounter' ) . length ) . toEqual ( 1 ) ;
643630 } ) ;
644631 } ) ;
632+
633+ describe ( 'being updated and should trigger update' , ( ) => {
634+ it ( 'dateFormat -> value should change format' , ( ) => {
635+ const date = new Date ( 2000 , 0 , 15 , 2 , 2 , 2 , 2 ) ,
636+ component = utils . createDatetime ( {
637+ dateFormat : 'YYYY-MM-DD' , timeFormat : false , defaultValue : date
638+ } ) ;
639+
640+ const valueBefore = utils . getInputValue ( component ) ;
641+ component . setProps ( { dateFormat : 'DD.MM.YYYY' } ) ;
642+ const valueAfter = utils . getInputValue ( component ) ;
643+
644+ expect ( valueBefore ) . not . toEqual ( valueAfter ) ;
645+ } ) ;
646+
647+ it ( 'UTC -> value should change format (true->false)' , ( ) => {
648+ const date = new Date ( 2000 , 0 , 15 , 2 , 2 , 2 , 2 ) ,
649+ momentDate = moment ( date ) ,
650+ component = utils . createDatetime ( { value : momentDate , utc : true } ) ;
651+
652+ const valueBefore = utils . getInputValue ( component ) ;
653+ component . setProps ( { utc : false } , ( ) => {
654+ const valueAfter = utils . getInputValue ( component ) ;
655+
656+ expect ( valueBefore ) . not . toEqual ( valueAfter ) ;
657+ } ) ;
658+ } ) ;
659+
660+ it ( 'UTC -> value should change format (false->true)' , ( ) => {
661+ const date = new Date ( 2000 , 0 , 15 , 2 , 2 , 2 , 2 ) ,
662+ momentDate = moment ( date ) ,
663+ component = utils . createDatetime ( { value : momentDate , utc : false } ) ;
664+
665+ const valueBefore = utils . getInputValue ( component ) ;
666+ component . setProps ( { utc : true } , ( ) => {
667+ const valueAfter = utils . getInputValue ( component ) ;
668+
669+ expect ( valueBefore ) . not . toEqual ( valueAfter ) ;
670+ } ) ;
671+ } ) ;
672+
673+ it ( 'locale -> picker should change language (viewMode=days)' , ( ) => {
674+ const component = utils . createDatetime ( { viewMode : 'days' , locale : 'nl' } ) ,
675+ weekdaysBefore = component . find ( '.rdtDays .dow' ) . map ( ( element ) =>
676+ element . text ( )
677+ ) ;
678+
679+ component . setProps ( { locale : 'sv' } ) ;
680+ const weekdaysAfter = component . find ( '.rdtDays .dow' ) . map ( ( element ) =>
681+ element . text ( )
682+ ) ;
683+
684+ expect ( weekdaysBefore ) . not . toEqual ( weekdaysAfter ) ;
685+ } ) ;
686+
687+ it ( 'locale -> picker should change language (viewMode=months)' , ( ) => {
688+ const component = utils . createDatetime ( { viewMode : 'months' , locale : 'nl' } ) ,
689+ monthsBefore = [ utils . getNthMonth ( component , 2 ) . text ( ) , utils . getNthMonth ( component , 4 ) . text ( ) ] ;
690+
691+ component . setProps ( { locale : 'sv' } ) ;
692+ const monthsAfter = [ utils . getNthMonth ( component , 2 ) . text ( ) , utils . getNthMonth ( component , 4 ) . text ( ) ] ;
693+
694+ expect ( monthsBefore ) . not . toEqual ( monthsAfter ) ;
695+ } ) ;
696+ } ) ;
645697 } ) ;
646698
647699 describe ( 'event listeners' , ( ) => {
0 commit comments