Fakultas Ilmu Komputer UI

index.test.tsx 618 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
import React from 'react';
import { render, fireEvent } from '@testing-library/react-native';

import ClientProfile from '.';

const mockedNavigate = jest.fn();

jest.mock('@react-navigation/native', () => {
  return {
    useNavigation: () => ({
      navigate: mockedNavigate,
    }),
  };
});

describe('ClientProfile', () => {
  it('renders correctly', () => {
    const { getByText } = render(<ClientProfile />);

    const changeProfileButton = getByText(/ubah profil/i);
    expect(changeProfileButton).toBeTruthy();
    fireEvent.press(changeProfileButton);

    expect(mockedNavigate).toBeCalled();
  });
});