import React from 'react';
import { render, fireEvent } from '@testing-library/react-native';
import { CloseButton } from '../components/CloseButton';
describe('CloseButton', () => {
it('should render close button text when visible is true', () => {
const { getByText } = render(
);
expect(getByText('✕')).toBeTruthy();
});
it('should not render when visible is false', () => {
const { queryByText } = render(
);
expect(queryByText('✕')).toBeNull();
});
it('should render by default when visible prop is omitted', () => {
const { getByText } = render(
);
expect(getByText('✕')).toBeTruthy();
});
it('should call onPress when pressed', () => {
const mockOnPress = jest.fn();
const { getByText } = render(
);
fireEvent.press(getByText('✕'));
expect(mockOnPress).toHaveBeenCalledTimes(1);
});
it('should not call onPress when not pressed', () => {
const mockOnPress = jest.fn();
render();
expect(mockOnPress).not.toHaveBeenCalled();
});
});