import { render, fireEvent } from '@testing-library/react-native';
import { MeasurementInput } from '../MeasurementInput';

describe('MeasurementInput', () => {
  it('renders correctly', () => {
    const { getByPlaceholderText } = render(<MeasurementInput units="foot" defaultValue={10} />);
    const input = getByPlaceholderText('Enter measurement');
    expect(input).toBeTruthy();
  });

  it('calls onValueSet when value is changed', () => {
    const mockOnValueSet = jest.fn();
    const { getByPlaceholderText } = render(<MeasurementInput units="foot" defaultValue={10} onValueSet={mockOnValueSet} />);
    const input = getByPlaceholderText('Enter measurement');
    fireEvent.changeText(input, '20');
    expect(mockOnValueSet).toHaveBeenCalledWith({ l: 20, u: 'foot' });
  });
});
