|
| 1 | +import { render } from '@testing-library/react-native'; |
| 2 | +import BottomTabBar from '@/components/tabbar/BottomTabBar'; |
| 3 | +import { BottomTabBarProps } from '@react-navigation/bottom-tabs'; |
| 4 | + |
| 5 | +describe('BottomTabBar Component', () => { |
| 6 | + it('should render all tabs', () => { |
| 7 | + const mockProps: BottomTabBarProps = { |
| 8 | + state: { |
| 9 | + index: 0, |
| 10 | + routes: [ |
| 11 | + { key: 'home', name: 'Home', params: undefined }, |
| 12 | + { key: 'recipients', name: 'Recipients', params: undefined }, |
| 13 | + { key: 'settings', name: 'Settings', params: undefined }, |
| 14 | + ], |
| 15 | + type: 'tab', |
| 16 | + stale: false, |
| 17 | + key: 'tab-key', |
| 18 | + routeNames: ['Home', 'Recipients', 'Settings'], |
| 19 | + history: [], |
| 20 | + preloadedRouteKeys: [], |
| 21 | + }, |
| 22 | + descriptors: { |
| 23 | + home: { |
| 24 | + options: { title: 'Home', tabBarIcon: undefined }, |
| 25 | + render: jest.fn(), |
| 26 | + route: { key: 'home', name: 'Home', params: undefined }, |
| 27 | + navigation: jest.fn() as any, |
| 28 | + }, |
| 29 | + recipients: { |
| 30 | + options: { title: 'Recipients', tabBarIcon: undefined }, |
| 31 | + render: jest.fn(), |
| 32 | + route: { key: 'recipients', name: 'Recipients', params: undefined }, |
| 33 | + navigation: jest.fn() as any, |
| 34 | + }, |
| 35 | + settings: { |
| 36 | + options: { title: 'Settings', tabBarIcon: undefined }, |
| 37 | + render: jest.fn(), |
| 38 | + route: { key: 'settings', name: 'Settings', params: undefined }, |
| 39 | + navigation: jest.fn() as any, |
| 40 | + }, |
| 41 | + }, |
| 42 | + navigation: { |
| 43 | + emit: jest.fn(), |
| 44 | + navigate: jest.fn(), |
| 45 | + reset: jest.fn(), |
| 46 | + goBack: jest.fn(), |
| 47 | + isFocused: jest.fn(), |
| 48 | + canGoBack: jest.fn(), |
| 49 | + getParent: jest.fn(), |
| 50 | + setParams: jest.fn(), |
| 51 | + getState: jest.fn(), |
| 52 | + dispatch: jest.fn(), |
| 53 | + navigateDeprecated: jest.fn(), |
| 54 | + preload: jest.fn(), |
| 55 | + getId: jest.fn(), |
| 56 | + setStateForNextRouteNamesChange: jest.fn(), |
| 57 | + } as any, |
| 58 | + insets: { |
| 59 | + top: 0, |
| 60 | + left: 0, |
| 61 | + right: 0, |
| 62 | + bottom: 0, |
| 63 | + }, |
| 64 | + }; |
| 65 | + |
| 66 | + const { getByText } = render(<BottomTabBar {...mockProps} />); |
| 67 | + expect(getByText('Home')).toBeTruthy(); |
| 68 | + expect(getByText('Recipients')).toBeTruthy(); |
| 69 | + expect(getByText('Settings')).toBeTruthy(); |
| 70 | + }); |
| 71 | +}); |
0 commit comments