import { shallow } from 'enzyme';
import React from 'react';

import PasswordResetForm from './PasswordResetForm';

describe('PasswordResetForm component', () => {
  let wrapper;

  const onPasswordReset = jest.fn();
  beforeEach(() => {
    wrapper = shallow(
      <PasswordResetForm
        search=""
        onPasswordReset={ onPasswordReset }
      />,
    );
  });

  it('renders PasswordRequestForm by default', () => {
    expect(wrapper.find('PasswordRequestForm')).toExist();
  });

  it('renders PasswordResponseForm if search in url', () => {
    wrapper.setProps({ search: '?token=testone' });

    expect(wrapper.find('PasswordResponseForm')).toExist();
    expect(wrapper.find('PasswordResponseForm'))
      .toHaveProp('onPasswordReset', onPasswordReset);
  });
});
