import reducer from "../../../../store/reducers/pattern/patternReducer";
import expect from "expect";
import {
  setPattern,
  setPatternError,
} from "../../../../store/actions/pattern/patternActions";
import { mockState } from "../../../../mockState";

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

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

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