var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
import { jsx } from "react/jsx-runtime";
import React from "react";
import { render, screen, fireEvent } from "@testing-library/react";
import { ThemeProvider, Dropdown } from "../..";
const dropdownProps = {
  label: "Find an activity to love",
  options: [
    { label: "Yoga", value: "yoga" },
    { label: "Crossfit", value: "crossfit" },
    { label: "Tenis", value: "tenis" },
    { label: "Soccer", value: "soccer" },
    { label: "Pilates", value: "pilates" },
    { label: "Run", value: "running" }
  ]
};
describe("<Dropdown />", () => {
  it("should match snapshot", () => {
    const { container } = render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Dropdown, __spreadValues({}, dropdownProps)) })
    );
    expect(container).toMatchSnapshot();
  });
  it("should match snapshot when disabled", () => {
    const { container } = render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Dropdown, __spreadProps(__spreadValues({}, dropdownProps), { disabled: true })) })
    );
    expect(container).toMatchSnapshot();
  });
  it("should match snapshot when full", () => {
    const { container } = render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Dropdown, __spreadProps(__spreadValues({}, dropdownProps), { full: true })) })
    );
    expect(container).toMatchSnapshot();
  });
  it("should match snapshot when has a selected value", () => {
    const selectedOption = {
      label: "Swimming",
      value: "swimming",
      selected: true
    };
    const props = dropdownProps;
    props.options.push(selectedOption);
    const { container } = render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Dropdown, __spreadProps(__spreadValues({}, props), { disabled: true })) })
    );
    expect(container).toMatchSnapshot();
  });
  it("should match snapshot with error", () => {
    const { container } = render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Dropdown, __spreadProps(__spreadValues({}, dropdownProps), { error: "Please, select one activity" })) })
    );
    expect(container).toMatchSnapshot();
  });
  it("should make label visible when open dropdown", () => {
    const { getByRole } = render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Dropdown, __spreadValues({}, dropdownProps)) })
    );
    fireEvent.click(getByRole("button"));
    screen.getAllByText("Find an activity to love");
  });
  it("should make label visible when has a selected option", () => {
    const selectedOption = {
      label: "Swimming",
      value: "swimming",
      selected: true
    };
    const props = dropdownProps;
    props.options.push(selectedOption);
    render(
      /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Dropdown, __spreadValues({}, props)) })
    );
    screen.getAllByText("Find an activity to love");
  });
});
