| 
									
										
										
										
											2021-04-09 02:56:48 +02:00
										 |  |  | import {Utils} from "../Utils"; | 
					
						
							|  |  |  | import {equal} from "assert"; | 
					
						
							|  |  |  | import T from "./TestHelper"; | 
					
						
							|  |  |  | import {Translation} from "../UI/i18n/Translation"; | 
					
						
							| 
									
										
										
										
											2021-06-27 20:35:38 +02:00
										 |  |  | import * as bike_repair_station from "../assets/layers/bike_repair_station/bike_repair_station.json" | 
					
						
							| 
									
										
										
										
											2021-08-07 23:11:34 +02:00
										 |  |  | import LayerConfig from "../Models/ThemeConfig/LayerConfig"; | 
					
						
							| 
									
										
										
										
											2021-04-09 02:56:48 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  | Utils.runningFromConsole = true; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-14 02:25:30 +02:00
										 |  |  | export default class ImageAttributionSpec extends T { | 
					
						
							|  |  |  |     constructor() { | 
					
						
							|  |  |  |         super( | 
					
						
							|  |  |  |             "ImageAttribution Tests", [ | 
					
						
							|  |  |  |                 [ | 
					
						
							|  |  |  |                     "Should find all the images", | 
					
						
							|  |  |  |                     () => { | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  |                         const pumps: LayerConfig = new LayerConfig(bike_repair_station) | 
					
						
							| 
									
										
										
										
											2021-05-14 02:25:30 +02:00
										 |  |  |                         const images = pumps.ExtractImages(); | 
					
						
							|  |  |  |                         const expectedValues = ['./assets/layers/bike_repair_station/repair_station.svg', | 
					
						
							|  |  |  |                             './assets/layers/bike_repair_station/repair_station_pump.svg', | 
					
						
							|  |  |  |                             './assets/layers/bike_repair_station/broken_pump_2.svg', | 
					
						
							|  |  |  |                             './assets/layers/bike_repair_station/pump.svg', | 
					
						
							|  |  |  |                             './assets/themes/cyclofix/fietsambassade_gent_logo_small.svg', | 
					
						
							|  |  |  |                             './assets/layers/bike_repair_station/pump_example_manual.jpg', | 
					
						
							|  |  |  |                             './assets/layers/bike_repair_station/pump_example.png', | 
					
						
							|  |  |  |                             './assets/layers/bike_repair_station/pump_example_round.jpg', | 
					
						
							|  |  |  |                             './assets/layers/bike_repair_station/repair_station_example.jpg'] | 
					
						
							|  |  |  |                         for (const expected of expectedValues) { | 
					
						
							|  |  |  |                             T.isTrue(images.has(expected), expected + " not found") | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 ], | 
					
						
							|  |  |  |                 [ | 
					
						
							|  |  |  |                     "Test image discovery regex", | 
					
						
							|  |  |  |                     () => { | 
					
						
							|  |  |  |                         const tr = new Translation({en: "XYZ <img src='a.svg'/> XYZ <img src=\"some image.svg\"></img> XYZ <img src=b.svg/>"}) | 
					
						
							|  |  |  |                         const images = new Set<string>(tr.ExtractImages(false)); | 
					
						
							|  |  |  |                         equal(3, images.size) | 
					
						
							|  |  |  |                         T.isTrue(images.has("a.svg"), "a.svg not found") | 
					
						
							|  |  |  |                         T.isTrue(images.has("b.svg"), "b.svg not found") | 
					
						
							|  |  |  |                         T.isTrue(images.has("some image.svg"), "some image.svg not found") | 
					
						
							| 
									
										
										
										
											2021-04-09 02:56:48 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-14 02:25:30 +02:00
										 |  |  |                     } | 
					
						
							|  |  |  |                 ] | 
					
						
							| 
									
										
										
										
											2021-04-09 02:57:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-09 02:56:48 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-14 02:25:30 +02:00
										 |  |  |             ]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |