Fakultas Ilmu Komputer UI

index.test.tsx 1.51 KB
Newer Older
1
2
3
4
import React from 'react';
import { render } from '@testing-library/react-native';

import ReadOnlyDietRecommendation from '.';
Wulan Mantiri's avatar
Wulan Mantiri committed
5
import { mockDietRecommendation } from 'mocks/dietRecommendation';
6
7
8
9
10
11
12

describe('ReadOnlyDietRecommendation', () => {
  it('shows "Belum ada rekomendasi" text if no recommendation is provided yet', () => {
    const { getByText } = render(<ReadOnlyDietRecommendation />);
    expect(getByText(/Belum ada rekomendasi/i)).toBeTruthy();
  });

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
40
41
42
43
44
  it('shows default no input text if recommendation is not fully provided yet', () => {
    const { getByText } = render(
      <ReadOnlyDietRecommendation
        data={{
          id: 1,
          nutritionist: 1,
          client: 1,
          client_plan_meal: null,
          nutritional_advice: '',
          lifestyle_advice: 'hai',
        }}
      />,
    );
    expect(getByText(/Belum ada nih, ditunggu yaa/i)).toBeTruthy();
  });

  it('shows default no input text if recommendation is not fully provided yet (2)', () => {
    const { getByText } = render(
      <ReadOnlyDietRecommendation
        data={{
          id: 1,
          nutritionist: 1,
          client: 1,
          client_plan_meal: null,
          nutritional_advice: 'bye',
          lifestyle_advice: '',
        }}
      />,
    );
    expect(getByText(/-/i)).toBeTruthy();
  });

45
46
47
48
49
50
51
  it('shows recommendation when provided', () => {
    const { getByText } = render(
      <ReadOnlyDietRecommendation data={mockDietRecommendation} />,
    );
    expect(getByText(/haiya/i)).toBeTruthy();
  });
});