import reducer from "../../../../store/reducers/pattern/updatePatternReducer";
import expect from "expect";
import {
  updatePattern,
  updatePatternError,
} from "../../../../store/actions/updatePattern/updatePatternActions";
import { mockState } from "../../../../mockState";

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

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

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