diff --git a/components/PaginationLoader.test.tsx b/components/PaginationLoader.test.tsx new file mode 100644 index 0000000..0fd5f2c --- /dev/null +++ b/components/PaginationLoader.test.tsx @@ -0,0 +1,41 @@ +import React from 'react' +import { render } from '@testing-library/react-native' +import PaginationLoader from './PaginationLoader' + +describe('PaginationLoader Component', () => { + describe('Basic Rendering', () => { + it('should render ActivityIndicator', () => { + const { UNSAFE_root } = render() + expect(UNSAFE_root).toBeTruthy() + }) + + it('should render with optional text', () => { + const { getByText } = render() + expect(getByText('加载更多...')).toBeTruthy() + }) + + it('should render without text when not provided', () => { + const { queryByText } = render() + expect(queryByText(/./)).toBeNull() + }) + }) + + describe('Theme Support', () => { + it('should use default color', () => { + 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('pagination-loader')).toBeTruthy() + }) + }) +}) diff --git a/components/PaginationLoader.tsx b/components/PaginationLoader.tsx new file mode 100644 index 0000000..3c9f1fc --- /dev/null +++ b/components/PaginationLoader.tsx @@ -0,0 +1,17 @@ +import React from 'react' +import { View, ActivityIndicator, ViewProps } from 'react-native' +import Text from './ui/Text' + +interface PaginationLoaderProps extends ViewProps { + text?: string + color?: string +} + +export default function PaginationLoader({ text, color = '#F5F5F5', testID, ...props }: PaginationLoaderProps) { + return ( + + + {text && {text}} + + ) +}