From bcb8ca80798e7bfeb5db8056cad100bec72125fd Mon Sep 17 00:00:00 2001 From: CarlosMealha Date: Tue, 7 Feb 2023 14:32:38 +0000 Subject: [PATCH] tests: adds various tests to showHidden --- src/actions/searchOffersActions.js | 10 +++++----- src/actions/searchOffersActions.spec.js | 12 ++++++++++++ .../HomePage/SearchArea/SearchArea.spec.js | 12 ++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/actions/searchOffersActions.js b/src/actions/searchOffersActions.js index 2003e4eb..e73bc249 100644 --- a/src/actions/searchOffersActions.js +++ b/src/actions/searchOffersActions.js @@ -94,6 +94,11 @@ export const adminEnableOffer = (offerIdx) => ({ offerIdx, }); +export const setShowHidden = (showHidden) => ({ + type: OfferSearchTypes.SET_SHOW_HIDDEN, + showHidden, +}); + export const resetAdvancedSearchFields = () => (dispatch) => { dispatch(setJobType(INITIAL_JOB_TYPE)); dispatch(setShowJobDurationSlider(false)); @@ -102,8 +107,3 @@ export const resetAdvancedSearchFields = () => (dispatch) => { dispatch(setTechs([])); dispatch(setShowHidden(false)); }; - -export const setShowHidden = (showHidden) => ({ - type: OfferSearchTypes.SET_SHOW_HIDDEN, - showHidden, -}); diff --git a/src/actions/searchOffersActions.spec.js b/src/actions/searchOffersActions.spec.js index fe87c2d6..c117e1dd 100644 --- a/src/actions/searchOffersActions.spec.js +++ b/src/actions/searchOffersActions.spec.js @@ -12,6 +12,7 @@ import { resetAdvancedSearchFields, setOffersFetchError, resetOffersFetchError, + setShowHidden, } from "./searchOffersActions"; import { INITIAL_JOB_TYPE, INITIAL_JOB_DURATION } from "../reducers/searchOffersReducer"; @@ -54,6 +55,17 @@ describe("Search Offers actions", () => { expect(setSearchValue(value)).toEqual(expectedAction); }); + it("should return Set Show Hidden action", () => { + + const showHidden = "show_hidden"; + const expectedAction = { + type: OfferSearchTypes.SET_SHOW_HIDDEN, + showHidden, + }; + + expect(setShowHidden(showHidden)).toEqual(expectedAction); + }); + it("should return Set Job Duration action", () => { const jobDuration = [1, 2]; diff --git a/src/components/HomePage/SearchArea/SearchArea.spec.js b/src/components/HomePage/SearchArea/SearchArea.spec.js index 3de94421..cd888bd3 100644 --- a/src/components/HomePage/SearchArea/SearchArea.spec.js +++ b/src/components/HomePage/SearchArea/SearchArea.spec.js @@ -79,6 +79,15 @@ describe("SearchArea", () => { { }} + setTechs={() => { }} + setJobDuration={() => { }} + setFields={() => { }} + setJobType={() => { }} + setSearchValue={() => { }} + setShowHidden={() => { }} /> , { initialState, theme } @@ -197,6 +206,7 @@ describe("SearchArea", () => { setJobDuration={() => { }} setFields={() => { }} setJobType={() => { }} + setShowHidden={() => { }} onSubmit={onSubmit} fields={[]} technologies={[]} @@ -272,6 +282,7 @@ describe("SearchArea", () => { jobDuration: [1, 2], fields: ["field1", "field2"], technologies: ["tech1", "tech2"], + showHidden: true, }, }; expect(mapStateToProps(mockState)).toEqual({ @@ -281,6 +292,7 @@ describe("SearchArea", () => { jobMaxDuration: 2, fields: ["field1", "field2"], technologies: ["tech1", "tech2"], + showHidden: true, }); });