mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-05-30 09:51:01 +00:00
c01abc79df
Added complete testing infrastructure with 160 passing tests across 34 suites: ✅ Test Infrastructure Setup: - Created babel.config.cjs with Expo preset - Configured jest.config.cjs with proper transformIgnorePatterns - Added jest.setup.cjs with comprehensive mocks - Added jest.setup.before.cjs for pre-setup configuration - Created __mocks__/ directory for custom mocks ✅ Component Tests (10 test files): - Badge.test.tsx (13 tests) - 100% coverage - Button.test.tsx (14 tests) - 100% statements - Card.test.tsx (7 tests) - Input.test.tsx (10 tests) - LoadingSkeleton.test.tsx (10 tests) - 93% coverage - TokenIcon.test.tsx (7 tests) - 100% coverage - BottomSheet.test.tsx (9 tests) - index.test.ts (1 test) ✅ Context Tests (4 test files): - AuthContext.test.tsx (7 tests) - PolkadotContext.test.tsx (10 tests) - BiometricAuthContext.test.tsx (11 tests) - LanguageContext.test.tsx (9 tests) ✅ Screen Tests (16 test files): - All major screens tested with provider wrappers - WelcomeScreen, SignIn/SignUp, Dashboard - Wallet, Swap, Staking, Governance - P2P, NFT Gallery, Education, Forum - BeCitizen, Security, Lock, Referral, Profile ✅ Utility Tests: - i18n/index.test.ts (4 tests) - lib/supabase.test.ts (3 tests) - theme/colors.test.ts (2 tests) ✅ App Integration Test: - App.test.tsx (3 tests) Coverage Metrics: - Statements: 37.74% (target: 35%) - Branches: 23.94% (target: 20%) - Functions: 28.53% (target: 25%) - Lines: 39.73% (target: 35%) All coverage thresholds met! ✅ Test Results: - 34/34 test suites passing - 160/160 tests passing - 17 snapshots Key Improvements: - Fixed ProfileScreen.tsx import bug (react-native import) - Added comprehensive mocks for Polkadot, Expo, Supabase - Created test-utils.tsx for provider wrappers - All tests use proper async/await patterns - Proper cleanup with React Testing Library Production Ready: Test infrastructure is complete and extensible.
76 lines
2.3 KiB
TypeScript
76 lines
2.3 KiB
TypeScript
import React from 'react';
|
|
import { render } from '@testing-library/react-native';
|
|
import { Badge } from '../Badge';
|
|
|
|
describe('Badge', () => {
|
|
it('should render with text', () => {
|
|
const { getByText } = render(<Badge>Test Badge</Badge>);
|
|
expect(getByText('Test Badge')).toBeTruthy();
|
|
});
|
|
|
|
it('should render default variant', () => {
|
|
const { getByText } = render(<Badge>Default</Badge>);
|
|
expect(getByText('Default')).toBeTruthy();
|
|
});
|
|
|
|
it('should render success variant', () => {
|
|
const { getByText } = render(<Badge variant="success">Success</Badge>);
|
|
expect(getByText('Success')).toBeTruthy();
|
|
});
|
|
|
|
it('should render error variant', () => {
|
|
const { getByText } = render(<Badge variant="error">Error</Badge>);
|
|
expect(getByText('Error')).toBeTruthy();
|
|
});
|
|
|
|
it('should render warning variant', () => {
|
|
const { getByText } = render(<Badge variant="warning">Warning</Badge>);
|
|
expect(getByText('Warning')).toBeTruthy();
|
|
});
|
|
|
|
it('should render info variant', () => {
|
|
const { getByText } = render(<Badge variant="info">Info</Badge>);
|
|
expect(getByText('Info')).toBeTruthy();
|
|
});
|
|
|
|
it('should render small size', () => {
|
|
const { getByText } = render(<Badge size="small">Small</Badge>);
|
|
expect(getByText('Small')).toBeTruthy();
|
|
});
|
|
|
|
it('should render medium size', () => {
|
|
const { getByText } = render(<Badge size="medium">Medium</Badge>);
|
|
expect(getByText('Medium')).toBeTruthy();
|
|
});
|
|
|
|
it('should render large size', () => {
|
|
const { getByText } = render(<Badge size="large">Large</Badge>);
|
|
expect(getByText('Large')).toBeTruthy();
|
|
});
|
|
|
|
it('should apply custom styles', () => {
|
|
const customStyle = { margin: 10 };
|
|
const { getByText } = render(<Badge style={customStyle}>Styled</Badge>);
|
|
expect(getByText('Styled')).toBeTruthy();
|
|
});
|
|
|
|
it('should handle testID prop', () => {
|
|
const { getByTestId } = render(<Badge testID="badge">Test</Badge>);
|
|
expect(getByTestId('badge')).toBeTruthy();
|
|
});
|
|
|
|
it('should render with number', () => {
|
|
const { getByText } = render(<Badge>{99}</Badge>);
|
|
expect(getByText('99')).toBeTruthy();
|
|
});
|
|
|
|
it('should render with icon', () => {
|
|
const { getByTestId } = render(
|
|
<Badge testID="badge">
|
|
<Badge>Inner Badge</Badge>
|
|
</Badge>
|
|
);
|
|
expect(getByTestId('badge')).toBeTruthy();
|
|
});
|
|
});
|