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

test('renders correctly Credential', () => {
  const tree = renderer
    .create(
      <Credential
        credential={undefined}
        active={false}
        onSelect={function (): void {
          throw new Error('Function not implemented.');
        }}
      />,
    )
    .toJSON();
  expect(tree).toMatchSnapshot();
});

test('check if field render properly', () => {
  const wrapper = shallow(
    <Credential credential={undefined} active={false} onSelect={jest.fn()} />,
  );
  expect(wrapper.find({testID: 'crdential'})).toBeDefined();
});

test('check if onPress works properly', () => {
  const wrapper = shallow(
    <Credential credential={undefined} active={false} onSelect={jest.fn()} />,
  );
  let value = wrapper.find({testID: 'crdential'});
  value.simulate('press');
  expect(value.simulate('press')).toBeTruthy();
});

test('check if view render properly', () => {
  const wrapper = shallow(
    <Credential credential={undefined} active={false} onSelect={jest.fn()} />,
  );
  expect(wrapper.find({testID: 'viewCred'})).toBeDefined();
});

test('check if view click works properly', () => {
  const wrapper = shallow(
    <Credential credential={undefined} active={false} onSelect={jest.fn()} />,
  );
  let value = wrapper.find({testID: 'viewCred'});
  value.simulate('press');
  expect(value.simulate('press')).toBeTruthy();
});
