import reducer from "../../../store/reducers/user/userReducer";
import expect from "expect";
import {
  resetUserState,
  setUser,
  setUserError,
} from "../../../store/actions/user/userActions";

describe("invite user reducer", () => {
  it("should set the state user", () => {
    expect(reducer(undefined, setUser({ username: "username" }))).toEqual({
      user: {
        username: "username",
      },
      errorMessage: "",
    });
  });

  it("should reset the state", () => {
    expect(reducer(undefined, resetUserState())).toEqual({
      user: {
        id: "",
        firstName: "",
        lastName: "",
        username: "",
        token: "",
        refreshToken: "",
      },
      errorMessage: "",
    });
  });

  it("should set the state error", () => {
    expect(reducer(undefined, setUserError('Error'))).toEqual({
      user: {
        id: "",
        firstName: "",
        lastName: "",
        username: "",
        token: "",
        refreshToken: "",
      },
      errorMessage: "Error",
    });
  });
});
