From 29c39a8962befb5f96d336e5a6625b3e00540787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Palma?= Date: Mon, 17 Apr 2023 22:26:22 +0100 Subject: [PATCH] add: tests for quick collapse edit func in company offers management widget --- .../Manage/CompanyOffersManagementWidget.js | 16 ++++----- .../CompanyOffersManagementWidget.spec.js | 36 ++----------------- 2 files changed, 9 insertions(+), 43 deletions(-) diff --git a/src/components/Company/Offers/Manage/CompanyOffersManagementWidget.js b/src/components/Company/Offers/Manage/CompanyOffersManagementWidget.js index f2b10f45..ada3e9ca 100644 --- a/src/components/Company/Offers/Manage/CompanyOffersManagementWidget.js +++ b/src/components/Company/Offers/Manage/CompanyOffersManagementWidget.js @@ -15,24 +15,15 @@ import { GenerateTableCellFromField, } from "../../../../utils/Table/utils"; import { columns } from "./CompanyOffersManagementSchema"; -import PropTypes from "prop-types"; -import useSession from "../../../../hooks/useSession"; import { OfferTitleFilter, PublishDateFilter, PublishEndDateFilter, LocationFilter, } from "../Filters/index"; -import { Edit as EditIcon } from "@material-ui/icons"; -import { Link } from "react-router-dom"; -import { addSnackbar } from "../../../../actions/notificationActions"; -import { connect } from "react-redux"; -import { RowActions } from "./CompanyOffersActions"; import Offer from "../../../HomePage/SearchResultsArea/Offer/Offer"; import { OfferConstants } from "../../../Offers/Form/OfferUtils"; -import { LocationFilter, OfferTitleFilter, PublishDateFilter, PublishEndDateFilter } from "../Filters/index"; import { RowActions } from "./CompanyOffersActions"; -import { columns } from "./CompanyOffersManagementSchema"; import OfferTitle from "./CompanyOffersTitle"; import CompanyOffersVisibilityActions from "./CompanyOffersVisibilityActions"; import CollapsedQuickOfferEdit from "./CollapsedQuickOfferEdit"; @@ -220,7 +211,12 @@ const CompanyOffersManagementWidget = ({ addSnackbar, isMobile }) => { - + diff --git a/src/components/Company/Offers/Manage/CompanyOffersManagementWidget.spec.js b/src/components/Company/Offers/Manage/CompanyOffersManagementWidget.spec.js index 42d1e305..7334b938 100644 --- a/src/components/Company/Offers/Manage/CompanyOffersManagementWidget.spec.js +++ b/src/components/Company/Offers/Manage/CompanyOffersManagementWidget.spec.js @@ -1,14 +1,7 @@ import React from "react"; import { - screen, - waitFor, - queryByText, - getByLabelText, - fireEvent, - act, - getByTestId, - queryByTestId, - queryByTitle, + screen, waitFor, queryByText, getByLabelText, + fireEvent, act, getByTestId, queryByTestId, queryByTitle, } from "@testing-library/react"; import CompanyOffersManagementWidget from "./CompanyOffersManagementWidget"; @@ -19,6 +12,7 @@ import * as companyOffersService from "../../../../services/companyOffersService import { hideOffer as hideOfferService, enableOffer as enableOfferService, + editOffer as editOfferService, } from "../../../../services/offerService"; import useSession from "../../../../hooks/useSession"; import { BrowserRouter } from "react-router-dom"; @@ -267,30 +261,6 @@ describe("App", () => { expect(addSnackbar).toHaveBeenCalledTimes(1); }); - it("Loads Empty Offers", async () => { - companyOffersService.fetchCompanyOffers.mockImplementationOnce( - () => new Promise((resolve) => resolve([])), - ); - // By waiting for act it executes all the async code at once - renderWithStoreAndTheme( - - - , - { initialState: {}, theme }, - ); - - await waitFor( - () => { - expect(screen.getByText("Offers Management")).toBeInTheDocument(); - - expect(screen.getByText("No offers here.")).toBeInTheDocument(); - }, - { - timeout: 1000, - }, - ); - }); - it("Error fetching offers", async () => { addSnackbar.mockImplementationOnce(() => ({ type: "" }));