-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
385 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { render } from "@testing-library/react"; | ||
import "../../i18n"; | ||
import { Provider } from "react-redux"; | ||
import { MemoryRouter } from "react-router-dom"; | ||
import { MockedProvider } from "@apollo/client/testing"; | ||
import configureStore from "redux-mock-store"; | ||
import { configureAxe } from "jest-axe"; | ||
|
||
import Header from "./Header"; | ||
|
||
const axe = configureAxe({ | ||
rules: { | ||
// disable landmark rules when testing isolated components. | ||
region: { enabled: false }, | ||
}, | ||
}); | ||
const mockStore = configureStore([]); | ||
const store = mockStore({ | ||
organization: { | ||
name: "Organization Name", | ||
}, | ||
user: { | ||
firstName: "Kim", | ||
lastName: "Mendoza", | ||
roleDescription: "Admin user", | ||
}, | ||
facilities: [ | ||
{ id: "1", name: "Facility One" }, | ||
{ id: "2", name: "Facility Two" }, | ||
], | ||
}); | ||
|
||
const mockNavigate = jest.fn(); | ||
jest.mock("react-router-dom", () => { | ||
const original = jest.requireActual("react-router-dom"); | ||
return { | ||
...original, | ||
useNavigate: () => mockNavigate, | ||
}; | ||
}); | ||
|
||
describe("Header", () => { | ||
it("displays correctly", async () => { | ||
render( | ||
<Provider store={store}> | ||
<MockedProvider> | ||
<MemoryRouter> | ||
<Header /> | ||
</MemoryRouter> | ||
</MockedProvider> | ||
</Provider> | ||
); | ||
expect(document.body).toMatchSnapshot(); | ||
expect(await axe(document.body)).toHaveNoViolations(); | ||
}); | ||
}); |
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
Oops, something went wrong.