mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2026-03-01 12:44:28 +00:00
26 lines
696 B
JavaScript
26 lines
696 B
JavaScript
/**
|
|
* Jest mock for ~/utils/iconRegistry
|
|
*
|
|
* In webpack, iconRegistry uses require.context to load branding SVGs and merge
|
|
* them with ocelotIcons. In Jest, we simply re-export ocelotIcons since branding
|
|
* SVGs are not available in the test environment.
|
|
*/
|
|
const { ocelotIcons } = require('@ocelot-social/ui/ocelot')
|
|
|
|
const iconRegistry = ocelotIcons
|
|
|
|
function toCamelCase(str) {
|
|
return str
|
|
.split('-')
|
|
.filter(Boolean)
|
|
.map((s, i) => (i === 0 ? s : s[0].toUpperCase() + s.slice(1)))
|
|
.join('')
|
|
}
|
|
|
|
function resolveIcon(iconName) {
|
|
if (!iconName) return undefined
|
|
return iconRegistry[toCamelCase(iconName)]
|
|
}
|
|
|
|
module.exports = { iconRegistry, toCamelCase, resolveIcon }
|