Fakultas Ilmu Komputer UI

index.test.tsx 901 Bytes
Newer Older
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
38
39
import React from 'react';
import { render, waitFor } from 'utils/testing';
import * as ROUTES from 'constants/routes';

import ProfileDietRecommendation from '.';

jest.mock('react-native-toast-message');
jest.mock('axios');
jest.mock('react-native-document-picker');

describe('ProfileDietRecommendation', () => {
  it('renders correctly', () => {
    render(<ProfileDietRecommendation />, ROUTES.profileDietRecommendation, {
      routeParams: {
        name: 'Doan',
        id: 1,
      },
    });
  });

  it('shows correct name', async () => {
    const { queryByText } = render(
      <ProfileDietRecommendation />,
      ROUTES.profileDietRecommendation,
      {
        routeParams: {
          name: 'Doan',
          id: 1,
        },
      },
    );

    await waitFor(() => expect(queryByText(/Rekomendasi/i)).toBeTruthy());
  });

  afterAll(() => {
    jest.clearAllMocks();
  });
});