import reducer from "../../../../store/reducers/ad/createAdReducer";
import expect from "expect";
import {
  setCreateAd,
  setCreateAdError,
} from "../../../../store/actions/createAd/createAdActions";
import { mockState } from "../../../../mockState";

describe("createAd reducer", () => {
  it("should return the initial state", () => {
    expect(reducer(undefined, {})).toEqual({
      ad: null,
      errorMessage: "",
    });
  });

  it("should set the state error", () => {
    expect(reducer(undefined, setCreateAdError("Error"))).toEqual({
      ad: null,
      errorMessage: "Error",
    });
  });

  it("should set the state success", () => {
    expect(reducer(undefined, setCreateAd(mockState.ads.ads[0]))).toEqual({
      ad: mockState.ads.ads[0],
      errorMessage: "",
    });
  });
});
