Fakultas Ilmu Komputer UI

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

import ClientNavigation, {
  WeeklyReportStackScreen,
  ExtQuestionnaireStackScreen,
} from '.';
import { NavigationContainer } from '@react-navigation/native';
9
10
import { mockUserContext } from 'mocks/userContext';
import { UserContext } from 'provider';
11
12

describe('ClientNavigation', () => {
13
14
15
16
17
18
19
20
21
  it('provides tab if user has finished onboarding', () => {
    const userProviderValues = {
      ...mockUserContext,
      user: {
        ...mockUserContext.user,
        is_finished_onboarding: true,
      },
    };

22
    render(
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
      <UserContext.Provider value={userProviderValues}>
        <NavigationContainer>
          <ClientNavigation />
        </NavigationContainer>
      </UserContext.Provider>,
    );
  });

  it('does not provide tab if user has not finished onboarding', () => {
    const userProviderValues = {
      ...mockUserContext,
      user: {
        ...mockUserContext.user,
        is_finished_onboarding: false,
      },
    };

    render(
      <UserContext.Provider value={userProviderValues}>
        <NavigationContainer>
          <ClientNavigation />
        </NavigationContainer>
      </UserContext.Provider>,
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
    );
  });

  test('weekly report renders correctly', () => {
    render(
      <NavigationContainer>
        <WeeklyReportStackScreen />
      </NavigationContainer>,
    );
  });

  test('profile renders correctly', () => {
    render(
      <NavigationContainer>
        <ExtQuestionnaireStackScreen />
      </NavigationContainer>,
    );
  });
});