import React from 'react';
import { render, screen } from '@testing-library/react';
import Profile from '../components/Profile';
import '@testing-library/jest-dom';

describe('Profile Component', () => {
  const mockProps = {
    imageSrc: '',
    employeeId: 'EMP123',
    EmployeeName: 'Jane Doe',
    location: 'New York',
  };

  it('renders initials when image is not provided', () => {
    render(<Profile {...mockProps} />);
    const avatar = screen.getByText('JD'); // J from Jane, D from Doe
    expect(avatar).toBeInTheDocument();
  });

  it('renders employee name, ID, and location', () => {
    render(<Profile {...mockProps} />);
    expect(screen.getByText('Jane Doe')).toBeInTheDocument();
    expect(screen.getByText('EMP123')).toBeInTheDocument();
    expect(screen.getByText('New York')).toBeInTheDocument();
  });

  it('does not render initials when image is provided', () => {
    render(<Profile {...mockProps} imageSrc="profile.jpg" />);
    expect(screen.getByRole('img')).toHaveAttribute('src', 'profile.jpg');
    expect(screen.queryByText('JD')).not.toBeInTheDocument();
  });
});
