Common front-end components for Web using the Tesseract design system, written for React. https://make.modal.sh/tesseract/web/react/common
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

Icon.test.tsx 1.0 KiB

1234567891011121314151617181920212223242526272829303132333435363738
  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. })