Fakultas Ilmu Komputer UI

index.test.tsx 1.03 KB
Newer Older
1
2
3
4
5
import React from 'react';
import { render } from 'utils/testing';
import * as ROUTES from 'constants/routes';

import ReadOnlyDietProfile from '.';
6
import { UserRole } from 'services/auth/models';
7

8
9
jest.useFakeTimers();

10
describe('ReadOnlyDietProfile', () => {
11
  it('renders correctly when role is nutritionist', () => {
12
    render(<ReadOnlyDietProfile />, ROUTES.clientProfileNutritionist, {
13
14
15
16
17
18
19
      routeParams: { id: 1, role: UserRole.NUTRITIONIST },
    });
  });

  it('renders correctly when role is admin', () => {
    render(<ReadOnlyDietProfile />, ROUTES.clientProfileNutritionist, {
      routeParams: { id: 1, role: UserRole.ADMIN },
20
21
    });
  });
22

23
24
25
26
27
  it('shows "Klien belum mengisi diet questionnaire" text if no questionnaire answer is provided yet', () => {
    const { getByText } = render(
      <ReadOnlyDietProfile />,
      ROUTES.clientProfileNutritionist,
      {
28
        routeParams: { id: null, role: UserRole.NUTRITIONIST },
29
30
31
32
      },
    );
    expect(getByText(/Klien belum mengisi diet questionnaire/i)).toBeTruthy();
  });
33
});