-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests for the alerts components in the company offer management page …
…and the create offer form
- Loading branch information
1 parent
4f85e5f
commit 95794d0
Showing
5 changed files
with
97 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from "react"; | ||
import { createTheme } from "@material-ui/core/styles"; | ||
import { BrowserRouter } from "react-router-dom"; | ||
import { renderWithStoreAndTheme, screen } from "../test-utils"; | ||
import useSession from "../hooks/useSession"; | ||
import { fetchCompanyApplicationState } from "../services/companyService"; | ||
import { MuiPickersUtilsProvider } from "@material-ui/pickers"; | ||
import DateFnsUtils from "@date-io/date-fns"; | ||
import CompanyOffersManagementPage from "./CompanyOffersManagementPage"; | ||
|
||
jest.mock("../hooks/useSession"); | ||
jest.mock("../services/offerService"); | ||
jest.mock("../services/companyService"); | ||
const theme = createTheme({}); | ||
|
||
// eslint-disable-next-line react/prop-types | ||
|
||
describe("Company Offers Management Page", () => { | ||
|
||
it("Should render alert if company is not approved", async () => { | ||
useSession.mockImplementation(() => ({ isLoggedIn: true, data: { company: { name: "Company Name" } } })); | ||
fetchCompanyApplicationState.mockImplementation(async () =>"UNVERIFIED"); | ||
|
||
await renderWithStoreAndTheme( | ||
<BrowserRouter> | ||
<MuiPickersUtilsProvider utils={DateFnsUtils}> | ||
<CompanyOffersManagementPage /> | ||
</MuiPickersUtilsProvider> | ||
</BrowserRouter>, | ||
{ initialState: {}, theme } | ||
); | ||
expect( screen.queryByTestId( 'Alert')).toBeInTheDocument(); | ||
|
||
}); | ||
|
||
it("Should not render alert if company is approved", async () => { | ||
useSession.mockImplementation(() => ({ isLoggedIn: true, data: { company: { name: "Company Name" } } })); | ||
fetchCompanyApplicationState.mockImplementation(async () =>"APPROVED"); | ||
|
||
await renderWithStoreAndTheme( | ||
<BrowserRouter> | ||
<MuiPickersUtilsProvider utils={DateFnsUtils}> | ||
<CompanyOffersManagementPage /> | ||
</MuiPickersUtilsProvider> | ||
</BrowserRouter>, | ||
{ initialState: {}, theme } | ||
); | ||
expect(await screen.queryByTestId("Alert")).not.toBeInTheDocument(); | ||
}); | ||
}); |