@@ -550,4 +550,89 @@ describe("ConfigService", () => {
550550 const actualFromNew = service . getConfig ( "view:X" ) ;
551551 expect ( actualFromNew ) . toEqual ( newFormat ) ;
552552 } ) ) ;
553+
554+ it ( "should migrate to new photo dataType" , fakeAsync ( ( ) => {
555+ const config = new Config ( ) ;
556+ const oldFormat = {
557+ attributes : {
558+ myPhoto : {
559+ dataType : "file" ,
560+ editComponent : "EditPhoto" ,
561+ label : "My Photo" ,
562+ } ,
563+ simpleFile : {
564+ dataType : "file" ,
565+ label : "Simple File attachment" ,
566+ } ,
567+ } ,
568+ } ;
569+
570+ const newFormat : EntityConfig = {
571+ attributes : {
572+ myPhoto : {
573+ dataType : "photo" ,
574+ label : "My Photo" ,
575+ } ,
576+ simpleFile : {
577+ dataType : "file" ,
578+ label : "Simple File attachment" ,
579+ } ,
580+ } ,
581+ } ;
582+
583+ config . data = { "entity:X" : oldFormat } ;
584+ updateSubject . next ( { entity : config , type : "update" } ) ;
585+ tick ( ) ;
586+ const actualFromOld = service . getConfig < EntityConfig > ( "entity:X" ) ;
587+ expect ( actualFromOld ) . toEqual ( newFormat ) ;
588+
589+ config . data = { "entity:X" : newFormat } ;
590+ updateSubject . next ( { entity : config , type : "update" } ) ;
591+ tick ( ) ;
592+ const actualFromNew = service . getConfig < EntityConfig > ( "entity:X" ) ;
593+ expect ( actualFromNew ) . toEqual ( newFormat ) ;
594+ } ) ) ;
595+
596+ it ( "should migrate to Percentage dataType" , fakeAsync ( ( ) => {
597+ const config = new Config ( ) ;
598+ const oldFormat = {
599+ attributes : {
600+ myPercentage : {
601+ dataType : "number" ,
602+ viewComponent : "DisplayPercentage" ,
603+ editComponent : "EditNumber" ,
604+ label : "My Percentage" ,
605+ } ,
606+ simpleNumber : {
607+ dataType : "number" ,
608+ label : "Simple Number" ,
609+ } ,
610+ } ,
611+ } ;
612+
613+ const newFormat : EntityConfig = {
614+ attributes : {
615+ myPercentage : {
616+ dataType : "percentage" ,
617+ label : "My Percentage" ,
618+ } ,
619+ simpleNumber : {
620+ dataType : "number" ,
621+ label : "Simple Number" ,
622+ } ,
623+ } ,
624+ } ;
625+
626+ config . data = { "entity:X" : oldFormat } ;
627+ updateSubject . next ( { entity : config , type : "update" } ) ;
628+ tick ( ) ;
629+ const actualFromOld = service . getConfig < EntityConfig > ( "entity:X" ) ;
630+ expect ( actualFromOld ) . toEqual ( newFormat ) ;
631+
632+ config . data = { "entity:X" : newFormat } ;
633+ updateSubject . next ( { entity : config , type : "update" } ) ;
634+ tick ( ) ;
635+ const actualFromNew = service . getConfig < EntityConfig > ( "entity:X" ) ;
636+ expect ( actualFromNew ) . toEqual ( newFormat ) ;
637+ } ) ) ;
553638} ) ;
0 commit comments