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.1 KiB

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