import reducer from "../../../store/reducers/candidates/candidateOptionsReducer";
import expect from "expect";
import {
  fetchCandidateOptionsSuccess,
  fetchCandidateOptionsError,
} from "../../../store/actions/candidates/candidatesActions";
import { mockState } from "../../../mockState";

describe("candidatesOptions reducer", () => {
  it("should return the initial state", () => {
    expect(reducer(undefined, {})).toEqual({
      options: [],
      errorMessage: "",
    });
  });

  it("should set the state error", () => {
    expect(reducer(undefined, fetchCandidateOptionsError("Error"))).toEqual({
      options: [],
      errorMessage: "Error",
    });
  });

  it("should set options", () => {
    expect(
      reducer(
        undefined,
        fetchCandidateOptionsSuccess(mockState.options.options)
      )
    ).toEqual({
      options: mockState.options.options,
      errorMessage: "",
    });
  });
});
