-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathDefiEmptyState.test.tsx
More file actions
37 lines (31 loc) · 1.16 KB
/
DefiEmptyState.test.tsx
File metadata and controls
37 lines (31 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React from 'react';
import { fireEvent } from '@testing-library/react-native';
import renderWithProvider from '../../../util/test/renderWithProvider';
import { DefiEmptyState } from './DefiEmptyState';
// Mock the navigation hook
const mockNavigate = jest.fn();
jest.mock('@react-navigation/native', () => ({
...jest.requireActual('@react-navigation/native'),
useNavigation: jest.fn(() => ({ navigate: mockNavigate })),
}));
describe('DefiEmptyState', () => {
afterEach(() => {
jest.clearAllMocks();
});
it('should render correctly', () => {
const { getByText } = renderWithProvider(<DefiEmptyState />);
expect(
getByText('Lend, borrow, and trade, right in your wallet.'),
).toBeDefined();
expect(getByText('Explore DeFi')).toBeDefined();
});
it('opens Explore on the main feed then Sites full view', () => {
const { getByText } = renderWithProvider(<DefiEmptyState />);
const button = getByText('Explore DeFi');
fireEvent.press(button);
expect(mockNavigate).toHaveBeenNthCalledWith(1, 'TrendingView', {
screen: 'TrendingFeed',
});
expect(mockNavigate).toHaveBeenNthCalledWith(2, 'SitesFullView');
});
});