text: /**
   * Test the HomePage
   */
  
  import React from 'react';
  import { shallow, mount } from 'enzyme';
  
  import HomePage from '../HomePage';
  import { mapDispatchToProps } from '../index';
  import { changeUsername } from '../actions';
  import { loadRepos } from '../../App/actions';
  
  describe('<HomePage />', () => {
    it('should render fetch the repos on mount if a username exists', () => {
      const submitSpy = jest.fn();
      mount(
        <HomePage
          username="Not Empty"
          onChangeUsername={() => {}}
          onSubmitForm={submitSpy}
        />
      );
      expect(submitSpy).toHaveBeenCalled();
    });
  
    it('should not call onSubmitForm if username is an empty string', () => {
      const submitSpy = jest.fn();
      mount(<HomePage onChangeUsername={() => {}} onSubmitForm={submitSpy} />);
      expect(submitSpy).not.toHaveBeenCalled();
    });
  
    it('should not call onSubmitForm if username is null', () => {
      const submitSpy = jest.fn();
      mount(
        <HomePage
          username=""
          onChangeUsername={() => {}}
          onSubmitForm={submitSpy}
        />
      );
      expect(submitSpy).not.toHaveBeenCalled();
    });
  
    describe('mapDispatchToProps', () => {
      describe('onChangeUsername', () => {
        it('should be injected', () => {
          const dispatch = jest.fn();
          const result = mapDispatchToProps(dispatch);
          expect(result.onChangeUsername).toBeDefined();
        });
  
        it('should dispatch changeUsername when called', () => {
          const dispatch = jest.fn();
          const result = mapDispatchToProps(dispatch);
          const username = 'flexdinesh';
          result.onChangeUsername({ target: { value: username } });
          expect(dispatch).toHaveBeenCalledWith(changeUsername(username));
        });
      });
  
      describe('onSubmitForm', () => {
        it('should be injected', () => {
          const dispatch = jest.fn();
          const result = mapDispatchToProps(dispatch);
          expect(result.onSubmitForm).toBeDefined();
        });
  
        it('should preventDefault if called with event', () => {
          const preventDefault = jest.fn();
          const result = mapDispatchToProps(() => {});
          const evt = { preventDefault };
          result.onSubmitForm(evt);
          expect(preventDefault).toHaveBeenCalledWith();
        });
      });
    });
  });
  