import { jsx } from "react/jsx-runtime";
import React from "react";
import { render, fireEvent } from "@testing-library/react-native";
import { Text } from "react-native";
import ThemeProvider from "../../Theme";
import List from "..";
const data = [
  { key: "Devin" },
  { key: "Dan" },
  { key: "Dominic" },
  { key: "Jackson" },
  { key: "James" },
  { key: "Joel" },
  { key: "John" },
  { key: "Jillian" },
  { key: "Jimmy" },
  { key: "Julie" }
];
describe("<List />", () => {
  describe("Snapshots", () => {
    describe("Without props", () => {
      it("should match snapshot with a default list", () => {
        const { toJSON } = render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
            List,
            {
              data,
              renderItem: ({ item }) => /* @__PURE__ */ jsx(List.Item, { children: /* @__PURE__ */ jsx(Text, { children: item.key }) })
            }
          ) })
        );
        expect(toJSON()).toMatchSnapshot();
      });
      it("should match snapshot with a small list", () => {
        const { toJSON } = render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
            List,
            {
              data,
              renderItem: ({ item }) => /* @__PURE__ */ jsx(List.Item, { small: true, children: /* @__PURE__ */ jsx(Text, { children: item.key }) })
            }
          ) })
        );
        expect(toJSON()).toMatchSnapshot();
      });
      it("should match snapshot with a list without divisors", () => {
        const { toJSON } = render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
            List,
            {
              data,
              renderItem: ({ item }) => /* @__PURE__ */ jsx(List.Item, { divided: false, children: /* @__PURE__ */ jsx(Text, { children: item.key }) })
            }
          ) })
        );
        expect(toJSON()).toMatchSnapshot();
      });
      it("should match snapshot with a horizontal list", () => {
        const { toJSON } = render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
            List,
            {
              horizontal: true,
              data,
              renderItem: ({ item }) => /* @__PURE__ */ jsx(List.Item, { children: /* @__PURE__ */ jsx(Text, { children: item.key }) })
            }
          ) })
        );
        expect(toJSON()).toMatchSnapshot();
      });
      it("should call onPress when selectable item is pressed", () => {
        const a = { key: "Devin", onPress: jest.fn() };
        const { getByText } = render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
            List,
            {
              data: [a],
              renderItem: ({ item }) => /* @__PURE__ */ jsx(List.Item, { onPress: item.onPress, children: /* @__PURE__ */ jsx(Text, { children: item.key }) })
            }
          ) })
        );
        const selectableItem = getByText(a.key);
        fireEvent.press(selectableItem);
        expect(a.onPress).toHaveBeenCalled();
      });
    });
  });
});
