diff --git a/components/LoadingState.test.tsx b/components/LoadingState.test.tsx new file mode 100644 index 0000000..1085487 --- /dev/null +++ b/components/LoadingState.test.tsx @@ -0,0 +1,41 @@ +import React from 'react' +import { render } from '@testing-library/react-native' +import LoadingState from './LoadingState' + +describe('LoadingState Component', () => { + describe('Basic Rendering', () => { + it('should render ActivityIndicator', () => { + const { UNSAFE_root } = render() + expect(UNSAFE_root).toBeTruthy() + }) + + it('should render with optional message', () => { + const { getByText } = render() + expect(getByText('Loading...')).toBeTruthy() + }) + + it('should render without message when not provided', () => { + const { queryByText } = render() + expect(queryByText(/./)).toBeNull() + }) + }) + + describe('Theme Support', () => { + it('should use light color by default', () => { + const { UNSAFE_root } = render() + expect(UNSAFE_root).toBeTruthy() + }) + + it('should accept custom color', () => { + const { UNSAFE_root } = render() + expect(UNSAFE_root).toBeTruthy() + }) + }) + + describe('Props', () => { + it('should accept testID prop', () => { + const { getByTestId } = render() + expect(getByTestId('loading-test')).toBeTruthy() + }) + }) +}) diff --git a/components/LoadingState.tsx b/components/LoadingState.tsx new file mode 100644 index 0000000..58586a9 --- /dev/null +++ b/components/LoadingState.tsx @@ -0,0 +1,17 @@ +import React from 'react' +import { View, ActivityIndicator, ViewProps } from 'react-native' +import Text from './ui/Text' + +interface LoadingStateProps extends ViewProps { + message?: string + color?: string +} + +export default function LoadingState({ message, color = '#F5F5F5', testID, ...props }: LoadingStateProps) { + return ( + + + {message && {message}} + + ) +}