Common front-end components for Web using the Tesseract design system, written for React. https://make.modal.sh/tesseract/web/react/common
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

39 rivejä
1.0 KiB

  1. import * as fc from 'fast-check'
  2. import * as Enzyme from 'enzyme'
  3. import * as React from 'react'
  4. import * as FeatherIcon from 'react-feather'
  5. import { paramCase } from 'param-case'
  6. import Icon from './Icon'
  7. const FEATHER_ICONS = Object.keys(FeatherIcon).map((k) => paramCase(k))
  8. it('should exist', () => {
  9. expect(Icon).toBeDefined()
  10. })
  11. it('should be a component', () => {
  12. expect(Icon).toBeComponent()
  13. })
  14. it('should render without crashing given required props', () => {
  15. expect(() => <Icon name="foo" />).not.toThrow()
  16. })
  17. describe('on XML icons', () => {
  18. test.each(FEATHER_ICONS)('should render the %p XML icon', (name) => {
  19. const wrapper = Enzyme.shallow(<Icon name={name} />)
  20. expect(wrapper).toHaveLength(1)
  21. })
  22. })
  23. it('should render null for an unknown icon name', () => {
  24. fc.assert(
  25. fc.property(fc.string().filter((v) => ![...FEATHER_ICONS].includes(paramCase(v.toLowerCase()))), (v) => {
  26. const wrapper = Enzyme.shallow(<Icon name={v} />)
  27. expect(wrapper.getElement()).toBe(null)
  28. }),
  29. )
  30. })