mirror of
				https://github.com/Mibew/simple-icons.git
				synced 2025-10-31 10:31:06 +03:00 
			
		
		
		
	Don't enumerate the get method (#1555)
* Test that all elements when iterating simpleIcons are objects * Refactor index template to hide .get method from enumeration
This commit is contained in:
		
							parent
							
								
									0c275b7173
								
							
						
					
					
						commit
						b1b2f339b8
					
				| @ -1,17 +1,21 @@ | |||||||
| var icons = {%s}; | var icons = {%s}; | ||||||
| 
 | 
 | ||||||
| module.exports = icons; | Object.defineProperty(icons, "get", { | ||||||
| module.exports.get = function(targetName) { |   enumerate: false, | ||||||
|   if (icons[targetName]) { |   value: function(targetName) { | ||||||
|     return icons[targetName]; |     if (icons[targetName]) { | ||||||
|   } else { |       return icons[targetName]; | ||||||
|     var normalizedName = targetName.toLowerCase(); |     } else { | ||||||
|     for (var iconName in icons) { |       var normalizedName = targetName.toLowerCase(); | ||||||
|       var icon = icons[iconName]; |       for (var iconName in icons) { | ||||||
|       if ((icon.title && icon.title.toLowerCase() === normalizedName) |         var icon = icons[iconName]; | ||||||
|        || (icon.slug && icon.slug === normalizedName)) { |         if ((icon.title && icon.title.toLowerCase() === normalizedName) | ||||||
|          return icon; |          || (icon.slug && icon.slug === normalizedName)) { | ||||||
|  |            return icon; | ||||||
|  |         } | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | }); | ||||||
|  | 
 | ||||||
|  | module.exports = icons; | ||||||
|  | |||||||
| @ -44,3 +44,11 @@ icons.forEach(icon => { | |||||||
|     expect(found.title).toEqual(icon.title); |     expect(found.title).toEqual(icon.title); | ||||||
|   }); |   }); | ||||||
| }); | }); | ||||||
|  | 
 | ||||||
|  | test(`Iterating over simpleIcons only exposes icons`, () => { | ||||||
|  |   const iconArray = Object.values(simpleIcons); | ||||||
|  |   for (let icon of iconArray) { | ||||||
|  |     expect(icon).toBeDefined(); | ||||||
|  |     expect(typeof icon).toBe('object'); | ||||||
|  |   } | ||||||
|  | }); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user