Common front-end components for Web using the Tesseract design system, written for React. https://make.modal.sh/tesseract/web/react/common
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

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