Rename 'get' to 'Get' on simpleIcons export (#5777)

This commit is contained in:
Eric Cornelissen 2021-05-28 12:16:50 +02:00 committed by GitHub
parent 8d21b9910b
commit f6b60e428f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 5 deletions

View file

@ -51,10 +51,10 @@ The API can then be used as follows, where `[ICON SLUG]` is replaced by a [slug]
const simpleIcons = require('simple-icons');
// Get a specific icon by its slug as:
simpleIcons.get('[ICON SLUG]');
simpleIcons.Get('[ICON SLUG]');
// For example:
const icon = simpleIcons.get('simpleicons');
const icon = simpleIcons.Get('simpleicons');
```
@ -102,7 +102,7 @@ This is useful if you want to do a computation on every icon:
const simpleIcons = require('simple-icons');
for (const title in simpleIcons) {
const icon = simpleIcons.get(title);
const icon = simpleIcons.Get(title);
// do stuff
}
```

View file

@ -1,10 +1,17 @@
var icons = {%s};
Object.defineProperty(icons, "get", {
Object.defineProperty(icons, "Get", {
enumerable: false,
value: function(targetName) {
return icons[targetName];
}
});
Object.defineProperty(icons, "get", {
enumerable: false,
value: function(targetName) {
return this.Get(targetName);
}
});
module.exports = icons;

View file

@ -59,7 +59,15 @@ icons.forEach(icon => {
}
});
test(`${icon.title} can be found by it's slug`, () => {
test(`'Get' ${icon.title} by its slug`, () => {
const found = simpleIcons.Get(slug);
expect(found).toBeDefined();
expect(found.title).toEqual(icon.title);
expect(found.hex).toEqual(icon.hex);
expect(found.source).toEqual(icon.source);
});
test(`'get' ${icon.title} by its slug`, () => {
const found = simpleIcons.get(slug);
expect(found).toBeDefined();
expect(found.title).toEqual(icon.title);