- Add useLoadingState hook with data/loading/error state management - Add useSimpleLoading hook for basic boolean loading state - Add useMultipleLoadingStates hook for tracking multiple items - Create Skeleton component with shimmer animation for placeholders - Create specialized skeletons: SkeletonText, SkeletonAvatar, SkeletonCard, SkeletonListItem, SkeletonBeneficiaryCard, SkeletonSensorCard - Create LoadingOverlay components: modal, inline, and card variants - Create ScreenLoading wrapper with loading/error/content states - Create RefreshableScreen with built-in pull-to-refresh - Create EmptyState and LoadingButtonState utility components - Add comprehensive tests for all components and hooks (61 tests passing) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
128 lines
3.4 KiB
TypeScript
128 lines
3.4 KiB
TypeScript
import React from 'react';
|
|
import { render } from '@testing-library/react-native';
|
|
import {
|
|
Skeleton,
|
|
SkeletonText,
|
|
SkeletonAvatar,
|
|
SkeletonCard,
|
|
SkeletonListItem,
|
|
SkeletonBeneficiaryCard,
|
|
SkeletonSensorCard,
|
|
} from '@/components/ui/Skeleton';
|
|
|
|
describe('Skeleton', () => {
|
|
it('renders with default props', () => {
|
|
const { toJSON } = render(<Skeleton />);
|
|
const tree = toJSON();
|
|
expect(tree).toBeTruthy();
|
|
});
|
|
|
|
it('renders with custom width and height', () => {
|
|
const { toJSON } = render(<Skeleton width={100} height={50} />);
|
|
const tree = toJSON();
|
|
expect(tree).toBeTruthy();
|
|
});
|
|
|
|
it('renders with custom border radius', () => {
|
|
const { toJSON } = render(<Skeleton borderRadius={20} />);
|
|
const tree = toJSON();
|
|
expect(tree).toBeTruthy();
|
|
});
|
|
|
|
it('renders with percentage width', () => {
|
|
const { toJSON } = render(<Skeleton width="80%" />);
|
|
const tree = toJSON();
|
|
expect(tree).toBeTruthy();
|
|
});
|
|
});
|
|
|
|
describe('SkeletonText', () => {
|
|
it('renders single line by default', () => {
|
|
const { toJSON } = render(<SkeletonText />);
|
|
const tree = toJSON();
|
|
expect(tree).toBeTruthy();
|
|
});
|
|
|
|
it('renders multiple lines', () => {
|
|
const { toJSON } = render(<SkeletonText lines={3} />);
|
|
const tree = toJSON();
|
|
expect(tree).toBeTruthy();
|
|
});
|
|
|
|
it('renders with custom line height', () => {
|
|
const { toJSON } = render(<SkeletonText lineHeight={20} />);
|
|
const tree = toJSON();
|
|
expect(tree).toBeTruthy();
|
|
});
|
|
|
|
it('renders with custom last line width', () => {
|
|
const { toJSON } = render(<SkeletonText lines={2} lastLineWidth="50%" />);
|
|
const tree = toJSON();
|
|
expect(tree).toBeTruthy();
|
|
});
|
|
});
|
|
|
|
describe('SkeletonAvatar', () => {
|
|
it('renders with default size', () => {
|
|
const { toJSON } = render(<SkeletonAvatar />);
|
|
const tree = toJSON();
|
|
expect(tree).toBeTruthy();
|
|
});
|
|
|
|
it('renders with custom size', () => {
|
|
const { toJSON } = render(<SkeletonAvatar size={64} />);
|
|
const tree = toJSON();
|
|
expect(tree).toBeTruthy();
|
|
});
|
|
});
|
|
|
|
describe('SkeletonCard', () => {
|
|
it('renders with default height', () => {
|
|
const { toJSON } = render(<SkeletonCard />);
|
|
const tree = toJSON();
|
|
expect(tree).toBeTruthy();
|
|
});
|
|
|
|
it('renders with custom height', () => {
|
|
const { toJSON } = render(<SkeletonCard height={200} />);
|
|
const tree = toJSON();
|
|
expect(tree).toBeTruthy();
|
|
});
|
|
});
|
|
|
|
describe('SkeletonListItem', () => {
|
|
it('renders with default props', () => {
|
|
const { toJSON } = render(<SkeletonListItem />);
|
|
const tree = toJSON();
|
|
expect(tree).toBeTruthy();
|
|
});
|
|
|
|
it('renders with custom avatar size', () => {
|
|
const { toJSON } = render(<SkeletonListItem avatarSize={64} />);
|
|
const tree = toJSON();
|
|
expect(tree).toBeTruthy();
|
|
});
|
|
|
|
it('renders with custom number of lines', () => {
|
|
const { toJSON } = render(<SkeletonListItem lines={3} />);
|
|
const tree = toJSON();
|
|
expect(tree).toBeTruthy();
|
|
});
|
|
});
|
|
|
|
describe('SkeletonBeneficiaryCard', () => {
|
|
it('renders beneficiary card skeleton', () => {
|
|
const { toJSON } = render(<SkeletonBeneficiaryCard />);
|
|
const tree = toJSON();
|
|
expect(tree).toBeTruthy();
|
|
});
|
|
});
|
|
|
|
describe('SkeletonSensorCard', () => {
|
|
it('renders sensor card skeleton', () => {
|
|
const { toJSON } = render(<SkeletonSensorCard />);
|
|
const tree = toJSON();
|
|
expect(tree).toBeTruthy();
|
|
});
|
|
});
|