import AppUpdateModal from '@components/AppUpdateModal';
import React from 'react';
import renderer from 'react-test-renderer';
import {shallow} from 'enzyme';

describe('Sholud test AppUpdateModal screen', () => {
  const hideModal = jest.fn();
  const updateApp = jest.fn();
  test('renders correctly AppUpdateModal', () => {
    const tree = renderer
      .create(
        <AppUpdateModal
          type="optional"
          description="test description"
          title="Random"
          hideModal={hideModal}
          updateApp={updateApp}
        />,
      )
      .toJSON();
    expect(tree).toMatchSnapshot();
  });

  test('check, update button exists', () => {
    const wrapper = shallow(
      <AppUpdateModal
        type="optional"
        description="test description"
        title="Random"
        hideModal={hideModal}
        updateApp={updateApp}
      />,
    );
    let value = wrapper.find({testID: 'updateButton'});
    expect(value).toHaveLength(1);
  });

  test('check, onPress works.', () => {
    const wrapper = shallow(
      <AppUpdateModal
        type="optional"
        description="test description"
        title="Random"
        hideModal={hideModal}
        updateApp={updateApp}
      />,
    );
    let value = wrapper.find({testID: 'updateButton'});
    value.simulate('press');
    expect(value.simulate('press')).toBeTruthy();
  });
});
