import React from 'react'; import { render, fireEvent } from '@testing-library/react-native'; import Calendar from '../Calendar'; describe('Calendar', () => { const minDate = new Date(2020, 0, 31); const maxDate = new Date(2020, 2, 20); const value = new Date(2020, 1, 1); describe('Snapshot', () => { it.each` element ${()} ${()} ${()} `('renders correctly', ({ element }) => { const { toJSON } = render(element); expect(toJSON()).toMatchSnapshot(); }); }); describe('Functionality', () => { it('triggers onChange with the correct date', () => { const callback = jest.fn(); const { getByText } = render( , ); const day24 = getByText('24'); fireEvent.press(day24.parent); expect(callback).toBeCalledWith(new Date(2020, 1, 24)); }); }); });