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,7 +1,8 @@ | |||||||
| var icons = {%s}; | var icons = {%s}; | ||||||
| 
 | 
 | ||||||
| module.exports = icons; | Object.defineProperty(icons, "get", { | ||||||
| module.exports.get = function(targetName) { |   enumerate: false, | ||||||
|  |   value: function(targetName) { | ||||||
|     if (icons[targetName]) { |     if (icons[targetName]) { | ||||||
|       return icons[targetName]; |       return icons[targetName]; | ||||||
|     } else { |     } else { | ||||||
| @ -15,3 +16,6 @@ module.exports.get = function(targetName) { | |||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | 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