import { render, screen, fireEvent } from '@testing-library/react';

import { Checkbox } from '.';

describe('testing the checkbox', () => {
  it('should trigger the onCheckedChange', () => {
    const onChange = vi.fn();

    render(<Checkbox onCheckedChange={onChange} defaultChecked={true} data-testid="chk" />);

    fireEvent.click(screen.getByTestId('chk'));

    expect(onChange).toBeCalledWith(false);
    expect(onChange).toBeCalledTimes(1);
  });
});
