Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

index.spec.tsx 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { render } from '@testing-library/react'
  2. import '@testing-library/jest-dom'
  3. import Divider from './index'
  4. describe('Divider', () => {
  5. it('renders with default props', () => {
  6. const { container } = render(<Divider />)
  7. const divider = container.firstChild as HTMLElement
  8. expect(divider).toHaveClass('w-full h-[0.5px] my-2')
  9. expect(divider).toHaveClass('bg-divider-regular')
  10. })
  11. it('renders horizontal solid divider correctly', () => {
  12. const { container } = render(<Divider type="horizontal" bgStyle="solid" />)
  13. const divider = container.firstChild as HTMLElement
  14. expect(divider).toHaveClass('w-full h-[0.5px] my-2')
  15. expect(divider).toHaveClass('bg-divider-regular')
  16. })
  17. it('renders vertical solid divider correctly', () => {
  18. const { container } = render(<Divider type="vertical" bgStyle="solid" />)
  19. const divider = container.firstChild as HTMLElement
  20. expect(divider).toHaveClass('w-[1px] h-full mx-2')
  21. expect(divider).toHaveClass('bg-divider-regular')
  22. })
  23. it('renders horizontal gradient divider correctly', () => {
  24. const { container } = render(<Divider type="horizontal" bgStyle="gradient" />)
  25. const divider = container.firstChild as HTMLElement
  26. expect(divider).toHaveClass('w-full h-[0.5px] my-2')
  27. expect(divider).toHaveClass('bg-gradient-to-r from-divider-regular to-background-gradient-mask-transparent')
  28. })
  29. it('renders vertical gradient divider correctly', () => {
  30. const { container } = render(<Divider type="vertical" bgStyle="gradient" />)
  31. const divider = container.firstChild as HTMLElement
  32. expect(divider).toHaveClass('w-[1px] h-full mx-2')
  33. expect(divider).toHaveClass('bg-gradient-to-r from-divider-regular to-background-gradient-mask-transparent')
  34. })
  35. it('applies custom className correctly', () => {
  36. const customClass = 'test-custom-class'
  37. const { container } = render(<Divider className={customClass} />)
  38. const divider = container.firstChild as HTMLElement
  39. expect(divider).toHaveClass(customClass)
  40. expect(divider).toHaveClass('w-full h-[0.5px] my-2')
  41. })
  42. it('applies custom style correctly', () => {
  43. const customStyle = { margin: '10px' }
  44. const { container } = render(<Divider style={customStyle} />)
  45. const divider = container.firstChild as HTMLElement
  46. expect(divider).toHaveStyle('margin: 10px')
  47. })
  48. })