Fakultas Ilmu Komputer UI

index.test.tsx 851 Bytes
Newer Older
1
import React from 'react';
2
import { render, waitFor } from 'utils/testing';
3
4

import DietReportForNutritionist from '.';
5
6
7
import { mockUserReportResponse } from '__mocks__/userReport';
import axios from 'axios';
import * as ROUTES from 'constants/routes';
8

9
10
jest.mock('axios');
const mockAxios = axios as jest.Mocked<typeof axios>;
11
12

describe('DietReportForNutritionist', () => {
13
14
15
  const userReports = [mockUserReportResponse];

  it('renders correctly', async () => {
16
17
18
19
20
21
    mockAxios.request.mockImplementationOnce(() =>
      Promise.resolve({
        status: 200,
        data: userReports,
      }),
    );
22
23
24
25
    render(<DietReportForNutritionist />, ROUTES.clientDietReportNutritionist, {
      routeParams: { id: 1 },
    });
    await waitFor(() => expect(mockAxios.request).toBeCalled());
26
  });
27
28
29
30

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