mirror of
https://github.com/dec0dOS/zero-ui.git
synced 2025-07-16 10:03:12 -07:00
test(HomeLoggedIn): add snapshot tests
This commit is contained in:
parent
ff96b43758
commit
e8413fecf0
2 changed files with 191 additions and 0 deletions
46
frontend/__tests__/unit/components/HomeLoggedIn.test.jsx
Normal file
46
frontend/__tests__/unit/components/HomeLoggedIn.test.jsx
Normal file
|
@ -0,0 +1,46 @@
|
|||
import { render, screen } from "@testing-library/react";
|
||||
import HomeLoggedIn from "components/HomeLoggedIn";
|
||||
import { Router } from "react-router-dom";
|
||||
import { createMemoryHistory } from "history";
|
||||
import { testNetwork } from "../../data/network";
|
||||
import API from "utils/API";
|
||||
import MockAdapter from "axios-mock-adapter";
|
||||
|
||||
describe("HomeLoggedIn", () => {
|
||||
it("renders HomeLoggedIn unchanged (no network)", async () => {
|
||||
const mock = new MockAdapter(API);
|
||||
const history = createMemoryHistory();
|
||||
|
||||
mock.onGet("network").reply(200, []);
|
||||
|
||||
const { container } = render(
|
||||
<Router history={history}>
|
||||
<HomeLoggedIn />
|
||||
</Router>
|
||||
);
|
||||
|
||||
expect(
|
||||
await screen.findByText(/Please create at least one network/i)
|
||||
).toBeInTheDocument();
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("renders HomeLoggedIn unchanged (with network)", async () => {
|
||||
const mock = new MockAdapter(API);
|
||||
const history = createMemoryHistory();
|
||||
|
||||
mock.onGet("network").reply(200, [testNetwork]);
|
||||
|
||||
const { container } = render(
|
||||
<Router history={history}>
|
||||
<HomeLoggedIn />
|
||||
</Router>
|
||||
);
|
||||
|
||||
expect(await screen.findByText(/0d303702cd0f1fc6/)).toBeInTheDocument();
|
||||
expect(await screen.findByText(/new-net-11166/)).toBeInTheDocument();
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue