| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import reducer from "../../../store/reducers/candidate/candidateReducer";
- import expect from "expect";
- import {
- fetchCandidateSuccess,
- fetchCandidateError,
- createCandidateCommentSuccess,
- createCandidateCommentError,
- deleteCandidateError,
- deleteCandidateSuccess,
- } from "../../../store/actions/candidate/candidateActions";
- import { mockState } from "../../../mockState";
-
- describe("candidate reducer", () => {
- it("should return the initial state", () => {
- expect(reducer(undefined, {})).toEqual({
- candidate: {},
- errorMessage: "",
- });
- });
-
- it("should set the state error when fetchCandidateError is called", () => {
- expect(reducer(undefined, fetchCandidateError("Error"))).toEqual({
- candidate: {},
- errorMessage: "Error",
- });
- });
-
- it("should set candidate when fetchCandidateSuccess is called", () => {
- expect(
- reducer(undefined, fetchCandidateSuccess(mockState.candidate.candidate))
- ).toEqual({
- candidate: mockState.candidate.candidate,
- errorMessage: "",
- });
- });
-
- it("should set the state error when createCandidateCommentError is called", () => {
- expect(reducer(undefined, createCandidateCommentError("Error"))).toEqual({
- candidate: {},
- errorMessage: "Error",
- });
- });
-
- // problem with comparing dateOfSending property of two states
- // it("should add new comment for canidate", () => {
- // const obj = {
- // myObj: { content: "sfsdfsd" },
- // user: mockState.user.user,
- // };
- // expect(
- // reducer(
- // { candidate: mockState.candidate.candidate, errorMessage: "" },
- // createCandidateCommentSuccess(obj)
- // )
- // ).toEqual({
- // candidate: { ...mockState.candidate.candidate, obj },
- // errorMessage: "",
- // });
- // });
-
- it("should set the state error when deleteCandidateError is called", () => {
- expect(reducer(undefined, deleteCandidateError("Error"))).toEqual({
- candidate: {},
- errorMessage: "Error",
- });
- });
-
- it("should set candidate when deleteCandidateSuccess is called", () => {
- fetchCandidateSuccess(mockState.candidate.candidate);
- expect(reducer(undefined, deleteCandidateSuccess())).toEqual({
- candidate: {},
- errorMessage: "",
- });
- });
- });
|