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