{"size": 1302, "ext": "js", "max_stars_repo_path": "src/components/__tests__/Main.test.js", "max_stars_repo_name": "hihuz/sb", "max_stars_repo_stars_event_min_datetime": "2017-04-12T20:39:59.000Z", "max_stars_repo_stars_event_max_datetime": "2017-04-12T20:39:59.000Z", "max_issues_repo_path": "src/components/__tests__/Main.test.js", "max_issues_repo_name": "hihuz/sb", "max_issues_repo_issues_event_min_datetime": "2020-12-12T14:08:06.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T12:24:09.000Z", "max_forks_repo_path": "src/components/__tests__/Main.test.js", "max_forks_repo_name": "hihuz/sb", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 7, "max_forks_count": null, "avg_line_length": 31.756097561, "max_line_length": 86, "alphanum_fraction": 0.5975422427}
import React from "react";
import { shallow } from "enzyme";
import { shallowToJson } from "enzyme-to-json";
import Main from "../Main";

describe("Main", () => {
  test("Snapshot", () => {
    const component = shallow(<Main articles={[]} />);
    const tree = shallowToJson(component);
    expect(tree).toMatchSnapshot();
  });

  test("Should render an Intro component and pass it its intro prop", () => {
    const intro = {
      title: "foo",
      text: "bar"
    };
    const component = shallow(<Main intro={intro} articles={[]} />);
    const child = component.find("Intro");
    expect(child.length).toEqual(1);
    expect(child.props().title).toEqual("foo");
    expect(child.props().text).toEqual("bar");
  });

  test("Should render a number of Sections components based off article prop", () => {
    const articles = [
      { name: "foo", title: "bla" },
      { name: "bar", title: "bleh" },
      { name: "baz", title: "bluh" }
    ];
    const component = shallow(<Main articles={articles} />);
    const sections = component.find("Section");
    expect(sections.length).toEqual(3);
    articles.forEach(({ name, title }, i) => {
      const child = sections.at(i);
      expect(child.props().title).toEqual(title);
      expect(child.props().name).toEqual(name);
    });
  });
});
