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.
 
 
 
 

42 regels
1.1 KiB

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