2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  {  LayerConfigJson  }  from  "../../../../Models/ThemeConfig/Json/LayerConfigJson"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  {  TagRenderingConfigJson  }  from  "../../../../Models/ThemeConfig/Json/TagRenderingConfigJson"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  LineRenderingConfigJson  from  "../../../../Models/ThemeConfig/Json/LineRenderingConfigJson"  
						 
					
						
							
								
									
										
										
										
											2022-03-29 00:20:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  {  
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ExpandRewrite , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    PrepareLayer , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    RewriteSpecial , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  from  "../../../../Models/ThemeConfig/Conversion/PrepareLayer"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  {  QuestionableTagRenderingConfigJson  }  from  "../../../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  RewritableConfigJson  from  "../../../../Models/ThemeConfig/Json/RewritableConfigJson"  
						 
					
						
							
								
									
										
										
										
											2023-02-03 04:48:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  {  describe ,  expect ,  it  }  from  "vitest"  
						 
					
						
							
								
									
										
										
										
											2022-04-03 03:26:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 02:37:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								describe ( "ExpandRewrite" ,  ( )  = >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    it ( "should not allow overlapping keys" ,  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  spec  =  < RewritableConfigJson < string > > { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            rewrite :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                sourceString :  [ "xyz" ,  "longer_xyz" ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                into :  [ [ "a" ,  "b" ] ,  [ "A, B" ] ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            renderings :  "The value of xyz is longer_xyz" , 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 02:37:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  rewrite  =  new  ExpandRewrite ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( ( )  = >  rewrite . convert ( spec ,  "test" ) ) . to . throw 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} )  
						 
					
						
							
								
									
										
										
										
											2022-03-24 03:11:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								describe ( "PrepareLayer" ,  ( )  = >  {  
						 
					
						
							
								
									
										
										
										
											2022-04-03 02:37:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    it ( "should expand rewrites in map renderings" ,  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  exampleLayer : LayerConfigJson  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            id :  "testlayer" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            source :  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                osmTags :  "key=value" , 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 02:37:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            mapRendering :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    rewrite :  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 02:37:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        sourceString :  [ "left|right" ,  "lr_offset" ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        into :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            [ "left" ,  - 6 ] , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            [ "right" ,  + 6 ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        ] , 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 02:37:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    renderings :  < LineRenderingConfigJson > { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        color :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            render :  "#888" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            mappings :  [ 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 02:37:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                                { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                                    if :  "parking:condition:left|right=free" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    then :  "#299921" , 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 02:37:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                                } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                                    if :  "parking:condition:left|right=disc" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    then :  "#219991" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            ] , 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-24 03:11:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        offset :  "lr_offset" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ] , 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 02:37:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  prep  =  new  PrepareLayer ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            tagRenderings : new  Map < string ,  TagRenderingConfigJson > ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            sharedLayers : new  Map < string ,  LayerConfigJson > ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 02:37:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  result  =  prep . convertStrict ( exampleLayer ,  "test" ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-24 03:11:29 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 02:37:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  expected  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            id :  "testlayer" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            source :  {  osmTags :  "key=value"  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            mapRendering :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    color :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        render :  "#888" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        mappings :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                if :  "parking:condition:left=free" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                then :  "#299921" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                if :  "parking:condition:left=disc" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                then :  "#219991" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        ] , 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-24 03:11:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    offset :  - 6 , 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 02:37:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    color :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        render :  "#888" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        mappings :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                if :  "parking:condition:right=free" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                then :  "#299921" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                if :  "parking:condition:right=disc" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                then :  "#219991" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        ] , 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-24 03:11:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    offset : 6 , 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 02:37:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ] , 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-09 00:10:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            titleIcons :  [ {  render :  "icons.defaults" ,  id :  "iconsdefaults"  } ] , 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 02:37:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-24 03:11:29 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-03 04:48:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        expect ( result ) . toEqual ( expected ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-03 02:37:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-24 03:11:29 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								} )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								describe ( "RewriteSpecial" ,  function  ( )  {  
						 
					
						
							
								
									
										
										
										
											2022-03-29 00:20:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    it ( "should rewrite the UK import button" ,  ( )  = >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  tr  =  < QuestionableTagRenderingConfigJson > { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            id :  "uk_addresses_import_button" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            render :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                special :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    type :  "import_button" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    targetLayer :  "address" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    tags :  "urpn_count=$urpn_count;ref:GB:uprn=$ref:GB:uprn$" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    text :  "Add this address" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    icon :  "./assets/themes/uk_addresses/housenumber_add.svg" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    location_picker :  "none" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 00:20:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  r  =  new  RewriteSpecial ( ) . convert ( tr ,  "test" ) . result 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-03 04:48:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        expect ( r ) . toEqual ( { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            id :  "uk_addresses_import_button" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            render :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                "*" :  "{import_button(address,urpn_count=$urpn_count;ref:GB:uprn=$ref:GB:uprn$,Add this address,./assets/themes/uk_addresses/housenumber_add.svg,,,,none,)}" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 00:20:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-08 21:40:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} )