{"size": 1019, "ext": "js", "max_stars_repo_path": "modules/__tests__/unit/withMediaQueries.spec.js", "max_stars_repo_name": "AWebOfBrown/React-MQL-Manager", "max_stars_repo_stars_event_min_datetime": "2017-11-20T07:12:14.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-05T09:46:26.000Z", "max_issues_repo_path": "modules/__tests__/unit/withMediaQueries.spec.js", "max_issues_repo_name": "AWebOfBrown/React-MQL-Manager", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modules/__tests__/unit/withMediaQueries.spec.js", "max_forks_repo_name": "AWebOfBrown/React-MQL-Manager", "max_forks_repo_forks_event_min_datetime": "2019-02-06T21:49:22.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-23T01:14:48.000Z"}
{"max_stars_count": 6, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 29.1142857143, "max_line_length": 76, "alphanum_fraction": 0.6614327772}
import React from "react";
import { withMediaQueries } from "../../index";
import { mount, shallow } from "enzyme";
import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-15";
configure({ adapter: new Adapter() });

const Wrapped = ({}) => <div>hello</div>;
let WrappedWMQ;
let shallowRender;
let customPropName = "customPropName";
beforeAll(() => {
  WrappedWMQ = withMediaQueries(Wrapped, customPropName);
  shallowRender = shallow(<WrappedWMQ />, {
    context: {
      __React_MQL_Manager_Subscription__: () => () => null,
      __React_MQL_Manager_Initial_State__: () => null
    }
  });
});

describe(`withMediaQueries`, () => {
  test(`unsubscribe should be a function`, () => {
    expect(typeof shallowRender.instance().unsubscribe === "function").toBe(
      true
    );
  });

  test(`should call unsubscribe on un-mount`, () => {
    const unsubSpy = jest.spyOn(shallowRender.instance(), "unsubscribe");
    shallowRender.unmount();
    expect(unsubSpy).toHaveBeenCalled();
  });
});
