import * as fc from 'fast-check'
import * as Enzyme from 'enzyme'
import * as React from 'react'
import * as FeatherIcon from 'react-feather'
import { paramCase } from 'param-case'
import Icon from './Icon'
const FEATHER_ICONS = Object.keys(FeatherIcon).map((k) => paramCase(k))
it('should exist', () => {
expect(Icon).toBeDefined()
})
it('should be a component', () => {
expect(Icon).toBeComponent()
})
it('should render without crashing given required props', () => {
expect(() => ).not.toThrow()
})
describe('on XML icons', () => {
test.each(FEATHER_ICONS)('should render the %p XML icon', (name) => {
const wrapper = Enzyme.shallow()
expect(wrapper).toHaveLength(1)
})
})
it('should render null for an unknown icon name', () => {
fc.assert(
fc.property(fc.string().filter((v) => ![...FEATHER_ICONS].includes(paramCase(v.toLowerCase()))), (v) => {
const wrapper = Enzyme.shallow()
expect(wrapper.getElement()).toBe(null)
}),
)
})