import React from "react";
import renderer from "react-test-renderer";
import { Select } from "./Select";

describe("<Select /> ", () => {
  const optionsData = [
    { id: 1, value: "first", name: "First" },
    { id: 2, value: "second", name: "Second" },
    { id: 3, value: "third", name: "Third" }
  ];

  test("Render Select correctly", () => {
    const tree = renderer
      .create(
        <Select
          placeholder="Select"
          default={{ value: "first", name: "First" }}
          options={optionsData}
        />
      )
      .toJSON();
    expect(tree).toMatchSnapshot();
  });

  test("None should be on first place in dropdown when passed", () => {
    const tree = renderer
      .create(
        <Select
          placeholder="Select"
          default={{ value: "first", name: "First" }}
          options={optionsData}
          includeNone
        />
      )
      .toJSON();
    expect(tree).toMatchSnapshot();
  });
});
