diff --git a/lib/load-simple-icons.js b/lib/load-simple-icons.js index 47af134356963191389a71394779b15860ca5511..976573d411c1023b85a89400b292e607c5c6e5c8 100644 --- a/lib/load-simple-icons.js +++ b/lib/load-simple-icons.js @@ -1,15 +1,13 @@ 'use strict' -const simpleIcons = require('simple-icons') +const originalSimpleIcons = require('simple-icons') const { svg2base64 } = require('./svg-helpers') function loadSimpleIcons() { - Object.keys(simpleIcons).forEach(key => { + const simpleIcons = {} + Object.keys(originalSimpleIcons).forEach(key => { const k = key.toLowerCase().replace(/ /g, '-') - if (k !== key) { - simpleIcons[k] = simpleIcons[key] - delete simpleIcons[key] - } + simpleIcons[k] = originalSimpleIcons[key] simpleIcons[k].base64 = { default: svg2base64( simpleIcons[k].svg.replace('<svg', `<svg fill="#${simpleIcons[k].hex}"`) diff --git a/lib/load-simple-icons.spec.js b/lib/load-simple-icons.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..3b420449991046f1f98e7b59ef876f9a27115bda --- /dev/null +++ b/lib/load-simple-icons.spec.js @@ -0,0 +1,29 @@ +'use strict' + +const { expect } = require('chai') +const loadSimpleIcons = require('./load-simple-icons') + +describe('loadSimpleIcons', function() { + let simpleIcons + before(function() { + simpleIcons = loadSimpleIcons() + }) + + it('prepares three color themes', function() { + expect(simpleIcons['sentry'].base64).to.have.all.keys( + 'default', + 'light', + 'dark' + ) + }) + + it('normalizes icon keys', function() { + // original key in the simple-icons is 'Linux Foundation' + expect(simpleIcons).to.include.key('linux-foundation') + }) + + // https://github.com/badges/shields/issues/4016 + it('excludes "get" function provided by the simple-icons', function() { + expect(simpleIcons).to.not.have.property('get') + }) +})