import React from 'react'; import { render, fireEvent } from '@testing-library/react-native'; import { Text } from 'react-native'; import { InlineWidget } from '../components/InlineWidget'; describe('InlineWidget rendering', () => { it('should render children when visible is true', () => { const { getByText } = render( Inline Survey ); expect(getByText('Inline Survey')).toBeTruthy(); }); it('should render close button when visible is true', () => { const { getByText } = render( Content ); expect(getByText('✕')).toBeTruthy(); }); it('should call onClose when close button is pressed', () => { const mockOnClose = jest.fn(); const { getByText } = render( Content ); fireEvent.press(getByText('✕')); expect(mockOnClose).toHaveBeenCalledTimes(1); }); it('should still render content when visible is false', () => { const { getByText } = render( Hidden Content ); expect(getByText('Hidden Content')).toBeTruthy(); }); it('should hide close button when visible is false', () => { const { queryByText } = render( Content ); expect(queryByText('✕')).toBeNull(); }); it('should not throw when onClose is not provided and close is pressed', () => { const { getByText } = render( Content ); expect(() => fireEvent.press(getByText('✕'))).not.toThrow(); }); it('should render multiple children', () => { const { getByText } = render( Child A Child B ); expect(getByText('Child A')).toBeTruthy(); expect(getByText('Child B')).toBeTruthy(); }); });