/* global context */
import { View } from "react-native";
import React from "react";
import { shallow } from "enzyme";
import {
  StandardSlice,
  standardRoles,
  LeadAndTwoSlice,
  leadAndTwoRoles,
  OpinionAndTwoSlice,
  opinionAndTwoRoles
} from "../slice";

export default () => {
  const ExampleChild = () => <View />;
  ExampleChild.displayName = "ExampleChild";

  const createItem = id => <ExampleChild id={id} />;

  context("Standard template", () => {
    it("renders a single child element", () => {
      const wrapper = shallow(
        <StandardSlice
          itemCount={1}
          renderItems={() => [createItem("standard-1")]}
        />
      );
      expect(wrapper).toMatchSnapshot(
        "1. Standard template renders a single child element"
      );
    });

    it("renders two child elements", () => {
      const wrapper = shallow(
        <StandardSlice
          itemCount={2}
          renderItems={() => [
            createItem("standard-1"),
            createItem("standard-2")
          ]}
        />
      );
      expect(wrapper).toMatchSnapshot(
        "2. Standard template renders two child elements"
      );
    });

    it("renders three child elements", () => {
      const wrapper = shallow(
        <StandardSlice
          itemCount={3}
          renderItems={() => [
            createItem("standard-1"),
            createItem("standard-2"),
            createItem("standard-3")
          ]}
        />
      );
      expect(wrapper).toMatchSnapshot(
        "3. Standard template renders three child elements"
      );
    });
  });

  context("Lead and two template", () => {
    it("renders a single child element", () => {
      const wrapper = shallow(
        <LeadAndTwoSlice lead={() => createItem("lead")} />
      );
      expect(wrapper).toMatchSnapshot(
        "4. Lead and two template renders a single child element"
      );
    });

    it("renders two child elements", () => {
      const wrapper = shallow(
        <LeadAndTwoSlice
          lead={() => createItem("lead")}
          renderSupports={() => [createItem("support-1")]}
        />
      );
      expect(wrapper).toMatchSnapshot(
        "5. Lead and two template renders two child elements"
      );
    });

    it("renders three child elements", () => {
      const wrapper = shallow(
        <LeadAndTwoSlice
          lead={() => createItem("lead")}
          renderSupports={() => [
            createItem("support-1"),
            createItem("support-2")
          ]}
        />
      );
      expect(wrapper).toMatchSnapshot(
        "6. Lead and two template renders three child elements"
      );
    });
  });

  context("Opinion and two template", () => {
    it("renders a single child element", () => {
      const wrapper = shallow(
        <OpinionAndTwoSlice opinion={() => createItem("opinion")} />
      );
      expect(wrapper).toMatchSnapshot(
        "7. Opinion and two template renders a single child element"
      );
    });

    it("renders two child elements", () => {
      const wrapper = shallow(
        <OpinionAndTwoSlice
          opinion={() => createItem("opinion")}
          renderSupports={() => [createItem("support-1")]}
        />
      );
      expect(wrapper).toMatchSnapshot(
        "8. Opinion and two template renders two child elements"
      );
    });

    it("renders three child elements", () => {
      const wrapper = shallow(
        <OpinionAndTwoSlice
          opinion={() => createItem("opinion")}
          renderSupports={() => [
            createItem("support-1"),
            createItem("support-2")
          ]}
        />
      );
      expect(wrapper).toMatchSnapshot(
        "9. Opinion and two template renders three child elements"
      );
    });
  });

  context("Roles", () => {
    it("should return the standard roles for tracking", () => {
      expect(standardRoles).toMatchSnapshot("10. Standard tracking roles");
    });

    it("should return the lead and two roles for tracking", () => {
      expect(leadAndTwoRoles).toMatchSnapshot(
        "11. Lead and two tracking roles"
      );
    });

    it("should return the opinion and two roles for tracking", () => {
      expect(opinionAndTwoRoles).toMatchSnapshot(
        "12. Opinion and two tracking roles"
      );
    });
  });
};

@@ -457,39 +457,45 @@
 () =%3E %7B%0A    it(%22
+should 
 render
-s
  a single child 
@@ -786,39 +786,45 @@
    %7D);%0A%0A    it(%22
+should 
 render
-s
  two child eleme
@@ -1169,39 +1169,45 @@
    %7D);%0A%0A    it(%22
+should 
 render
-s
  three child ele
@@ -1643,39 +1643,45 @@
 () =%3E %7B%0A    it(%22
+should 
 render
-s
  a single child 
@@ -1921,39 +1921,45 @@
    %7D);%0A%0A    it(%22
+should 
 render
-s
  two child eleme
@@ -2268,39 +2268,45 @@
    %7D);%0A%0A    it(%22
+should 
 render
-s
  three child ele
@@ -2740,23 +2740,29 @@
     it(%22
+should 
 render
-s
  a singl
@@ -3030,23 +3030,29 @@
     it(%22
+should 
 render
-s
  two chi
@@ -3389,23 +3389,29 @@
     it(%22
+should 
 render
-s
  three c

rename Slice package tests (#833)