You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

statusReducer.test.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import reducer from "../../../../store/reducers/processes/statusReducer";
  2. import expect from "expect";
  3. import {
  4. setStatuses,
  5. setStatusesError,
  6. changeStatusIsCheckedValue,
  7. } from "../../../../store/actions/processes/statusAction";
  8. describe("status reducer", () => {
  9. it("should return the initial state", () => {
  10. expect(reducer(undefined, {})).toEqual({
  11. statuses: [],
  12. errorMessage: "",
  13. });
  14. });
  15. it("should set the state error", () => {
  16. expect(reducer(undefined, setStatusesError("Error"))).toEqual({
  17. statuses: [],
  18. errorMessage: "Error",
  19. });
  20. });
  21. it("should set the state success", () => {
  22. expect(reducer(undefined, setStatuses(["option1", "option2"]))).toEqual({
  23. statuses: ["option1", "option2"],
  24. errorMessage: "",
  25. });
  26. });
  27. it("should not change status because there is no option with name which we send as argument", async () => {
  28. expect(
  29. reducer(
  30. {
  31. statuses: [{ name: "option1" }, { name: "option2" }],
  32. errorMessage: "",
  33. },
  34. changeStatusIsCheckedValue("option3")
  35. )
  36. ).toEqual({
  37. statuses: [{ name: "option1" }, { name: "option2" }],
  38. errorMessage: "",
  39. });
  40. });
  41. it("should not change status because there is option with name which we send as argument", async () => {
  42. expect(
  43. reducer(
  44. {
  45. statuses: [
  46. { name: "option1", isChecked: false },
  47. { name: "option2", isChecked: false },
  48. ],
  49. errorMessage: "",
  50. },
  51. changeStatusIsCheckedValue("option1")
  52. )
  53. ).toEqual({
  54. statuses: [
  55. { name: "option1", isChecked: true },
  56. { name: "option2", isChecked: false },
  57. ],
  58. errorMessage: "",
  59. });
  60. });
  61. });