Fakultas Ilmu Komputer UI

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

import Datepicker from '.';

describe('Datepicker component', () => {
  let value: Date = new Date();

  const props = {
    value,
    onChange: (v: Date) => (value = v),
  };

  it('renders correctly', () => {
    render(<Datepicker {...props} />);
  });

  it('renders correctly with error message', () => {
    render(<Datepicker {...props} errorMessage="error" />);
  });

  it('opens dialog when pressed', () => {
    const { getByTestId } = render(<Datepicker {...props} />);

    const datepickerButton = getByTestId('datepickertrigger');
    expect(datepickerButton).toBeTruthy();
  });
});