import reducer from "../../../../store/reducers/pattern/createPatternReducer";
import expect from "expect";
import {
  createPattern,
  createPatternError,
} from "../../../../store/actions/createPattern/createPatternActions";
import { mockState } from "../../../../mockState";

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

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

  it("should set the state success", () => {
    expect(
      reducer(undefined, createPattern(mockState.patterns.patterns))
    ).toEqual({
      pattern: mockState.patterns.patterns,
      errorMessage: "",
    });
  });
});
