zero-ui/frontend/__tests__/unit/components/NetworkHeader.test.jsx
David Laganiere 8931a780aa
test: reorganize folder structure and files
The specific test files used for snapshots only have been integrated in
each component's test file so that all tests, including the snapshot are
located in a single test file.

Also as more tests were added, it seems like a better idea to have test
data in a separate file on its own rather than import test data from
another test file.

FInally, with all these changes, Jest wanted to have snapshots taken
again thus why the snapshot files were updated too.
2023-01-15 10:39:35 -05:00

30 lines
914 B
JavaScript

import { render, screen } from "@testing-library/react";
import NetworkHeader from "components/NetworkHeader";
import { testNetwork } from "../../data/network";
describe("NetworkHeader", () => {
it("renders NetworkHeader unchanged", () => {
const { container } = render(<NetworkHeader network={testNetwork} />);
expect(container).toMatchSnapshot();
});
test("renders NetworkHeader with a test network", () => {
render(<NetworkHeader network={testNetwork} />);
const networkId = screen.getByRole("heading", {
name: "0d303702cd0f1fc6",
level: 5,
});
const networkName = screen.getByRole("heading", {
name: "new-net-11166",
level: 6,
});
const networkDescription = screen.getByText(/Test Network/);
expect(networkId).toBeInTheDocument();
expect(networkName).toBeInTheDocument();
expect(networkDescription).toBeInTheDocument();
});
});