import { jsx } from "react/jsx-runtime";
import React from "react";
import { render, fireEvent } from "@testing-library/react-native";
import ThemeProvider from "../../Theme";
import Slider from "./Slider";
describe("<Slider />", () => {
  describe("Snapshots", () => {
    describe("With one marker", () => {
      it("should match snapshot with default Slider", () => {
        const { root, toJSON } = render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Slider, {}) })
        );
        expect(toJSON(root)).toMatchSnapshot();
      });
      it("should match snapshot with Slider with labels", () => {
        const { root, toJSON } = render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Slider, { minLabel: 0, maxLabel: 10 }) })
        );
        expect(toJSON(root)).toMatchSnapshot();
      });
      it("should match snapshot with Slider snapped", () => {
        const { root, toJSON } = render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Slider, { snapped: true }) })
        );
        expect(toJSON(root)).toMatchSnapshot();
      });
    });
    describe("With two markers", () => {
      it("should match snapshot", () => {
        const { root, toJSON } = render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Slider, { values: [3, 7] }) })
        );
        expect(toJSON(root)).toMatchSnapshot();
      });
      it("should match snapshot with Slider snapped", () => {
        const { root, toJSON } = render(
          /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Slider, { values: [3, 7], snapped: true }) })
        );
        expect(toJSON(root)).toMatchSnapshot();
      });
    });
  });
  describe("Labels", () => {
    it("should render labels", () => {
      const { getByText } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Slider, { maxLabel: "max", minLabel: "min" }) })
      );
      expect(getByText("max")).toHaveTextContent("max");
      expect(getByText("min")).toHaveTextContent("min");
    });
  });
  describe("Tooltip", () => {
    it("should render tooltip", () => {
      const { root, getByText, getByRole, toJSON } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
          Slider,
          {
            values: [0],
            tooltip: [
              {
                ribbon: "ribbon",
                title: "title",
                description: "description",
                visible: true
              }
            ]
          }
        ) })
      );
      fireEvent(getByRole("adjustable"), "responderGrant", {
        touchHistory: { touchBank: {} }
      });
      expect(getByText("ribbon")).toBeTruthy();
      expect(getByText("title")).toBeTruthy();
      expect(getByText("description")).toBeTruthy();
      expect(toJSON(root)).toMatchSnapshot();
    });
    it("should render tooltip on a specific step", () => {
      const { root, getByText, getByRole, toJSON } = render(
        /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
          Slider,
          {
            values: [2],
            tooltip: [
              {
                ribbon: "ribbon",
                title: "title",
                description: "description",
                visible: true,
                step: 2
              }
            ]
          }
        ) })
      );
      fireEvent(getByRole("adjustable"), "responderGrant", {
        touchHistory: { touchBank: {} }
      });
      expect(getByText("ribbon")).toBeTruthy();
      expect(getByText("title")).toBeTruthy();
      expect(getByText("description")).toBeTruthy();
      expect(toJSON(root)).toMatchSnapshot();
    });
  });
});
