import { renderHook } from "@testing-library/react-hooks";
import configureStore from "redux-mock-store";

const mockStore = configureStore();

import { useScreenData } from "../useScreenData";
import * as React from "react";
import { Provider } from "react-redux";

describe("useScreenData", () => {
  const river_id_2 = {};
  const river_id_1 = {};

  const store = mockStore({
    rivers: { river_id_1, river_id_2 },
  });

  const wrapper: React.FC<any> = ({ children }) => (
    <Provider store={store}>{children}</Provider>
  );

  it("should return screen data for passed screen id", () => {
    const { result } = renderHook(() => useScreenData("river_id_1"), {
      wrapper,
    });

    expect(result.current).toBe(river_id_1);
  });

  it("should return undefined if screen id doesnt exist in rivers", () => {
    const { result } = renderHook(() => useScreenData("non-existing-id"), {
      wrapper,
    });

    expect(result.current).toBe(undefined);
  });
});
