{"size": 2243, "ext": "js", "max_stars_repo_path": "packages/canner/test/hocs/id.test.js", "max_stars_repo_name": "adileo/canner", "max_stars_repo_stars_event_min_datetime": "2021-09-28T03:54:58.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-21T23:09:43.000Z", "max_issues_repo_path": "packages/canner/test/hocs/id.test.js", "max_issues_repo_name": "adileo/canner", "max_issues_repo_issues_event_min_datetime": "2019-04-30T05:38:48.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-30T05:38:48.000Z", "max_forks_repo_path": "packages/canner/test/hocs/id.test.js", "max_forks_repo_name": "adileo/canner", "max_forks_repo_forks_event_min_datetime": "2022-03-05T22:37:54.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-05T22:37:54.000Z"}
{"max_stars_count": 9, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 28.7564102564, "max_line_length": 76, "alphanum_fraction": 0.6090057958}
/**
|--------------------------------------------------
| this is just for copy and past
|--------------------------------------------------
*/


import * as React from 'react';
import Enzyme, { mount } from 'enzyme';
import toJson from 'enzyme-to-json';
import Adapter from 'enzyme-adapter-react-16';
import withConnectContext from '../../src/hocs/connectContext';
import {HOCContext as Context} from '../../src/hocs/context';

Enzyme.configure({ adapter: new Adapter() });

describe('withConnectContext', () => {
  let WrapperComponent, props, MockComponent, context,
  mockFetch, mockSubscribe, mockRequest, mockDeploy, mockReset;

  beforeEach(() => {
    MockComponent = function MockComponent() {
      return (<div>Component</div>);
    }
    props = {
      id: undefined,
      keyName: 'posts',
      pattern: 'array',
      routes: ['posts']
    }

    mockFetch = jest.fn();
    mockSubscribe = jest.fn();
    mockRequest = jest.fn();
    mockReset = jest.fn();
    mockDeploy = jest.fn();

    context = {
      componentId: undefined,
      query: undefined,
      fetch: mockFetch,
      subscribe: mockSubscribe,
      request: mockRequest,
      deploy: mockDeploy,
      reset: mockReset
    }

    WrapperComponent = withConnectContext(MockComponent);
  });

  it('should render', () => {
    const wrapper = mount(
      <Context.Provider value={context}>
        <WrapperComponent
          {...props}
        />
      </Context.Provider>
    );
    expect(toJson(wrapper)).toMatchSnapshot();
  });

  it('should pass props', () => {
    const wrapper = mount(
      <Context.Provider value={context}>
        <WrapperComponent
          {...props}
        />
      </Context.Provider>
    );
    expect(wrapper.find(MockComponent).props()).toHaveProperty('deploy');
    expect(wrapper.find(MockComponent).props()).toHaveProperty('fetch');
    expect(wrapper.find(MockComponent).props()).toHaveProperty('keyName');
    expect(wrapper.find(MockComponent).props()).toHaveProperty('query');
    expect(wrapper.find(MockComponent).props()).toHaveProperty('request');
    expect(wrapper.find(MockComponent).props()).toHaveProperty('reset');
    expect(wrapper.find(MockComponent).props()).toHaveProperty('subscribe');
  });
});