client-card-comment.test.tsx 1.0 KB

123456789101112131415161718192021222324252627
  1. import { render, screen } from '@testing-library/react';
  2. import { describe, expect, it } from 'vitest';
  3. import ClientCardComment from '@/components/clients/ClientCardComment';
  4. describe('ClientCardComment', () => {
  5. it('renders a client comment in the card', () => {
  6. render(<ClientCardComment comment={'Primary mobile client\nLine two'} />);
  7. const comment = screen.getByText(/Primary mobile client/);
  8. expect(comment.className).toContain('client-card-comment');
  9. expect(comment.textContent).toBe('Primary mobile client\nLine two');
  10. expect(comment.getAttribute('title')).toBe('Primary mobile client\nLine two');
  11. });
  12. it('supports the compact desktop style', () => {
  13. render(<ClientCardComment comment="Desktop comment" className="sub" />);
  14. expect(screen.getByText('Desktop comment').className).toBe('sub');
  15. });
  16. it('renders nothing when no comment is set', () => {
  17. const { container } = render(<ClientCardComment comment="" />);
  18. expect(container.childElementCount).toBe(0);
  19. });
  20. });