Fakultas Ilmu Komputer UI

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

import AllCartsExpiredPage from '.';

const mockedNavigate = jest.fn();

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

describe('AllCartsExpiredPage', () => {
  it('has call-to-action button that navigates to Dietela Quiz', () => {
    const { getByText, queryByText } = render(<AllCartsExpiredPage />);
    expect(queryByText(/konsultasi lagi/i)).toBeTruthy();
    fireEvent.press(getByText(/konsultasi lagi/i));

    expect(mockedNavigate).toHaveBeenCalled();
  });
});