mirror of
https://github.com/dec0dOS/zero-ui.git
synced 2025-07-16 10:03:12 -07:00
test: tests for NetworkHeader component
This commit is contained in:
parent
f69d82e4dc
commit
ce59c1c3ce
3 changed files with 134 additions and 0 deletions
8
frontend/__tests__/unit/NetworkHeader.snapshot.jsx
Normal file
8
frontend/__tests__/unit/NetworkHeader.snapshot.jsx
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import { render } from "@testing-library/react";
|
||||||
|
import NetworkHeader from "../../src/components/NetworkHeader";
|
||||||
|
import { testNetwork } from "./NetworkHeader.test";
|
||||||
|
|
||||||
|
it("renders HomeLoggedOut unchanged", () => {
|
||||||
|
const { container } = render(<NetworkHeader network={testNetwork} />);
|
||||||
|
expect(container).toMatchSnapshot();
|
||||||
|
});
|
98
frontend/__tests__/unit/NetworkHeader.test.jsx
Normal file
98
frontend/__tests__/unit/NetworkHeader.test.jsx
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
import { render, screen } from "@testing-library/react";
|
||||||
|
import NetworkHeader from "../../src/components/NetworkHeader";
|
||||||
|
//import testNetwork from "./utils/testNetwork";
|
||||||
|
|
||||||
|
export const testNetwork = {
|
||||||
|
id: "0d303702cd0f1fc6",
|
||||||
|
clock: 1672834445703,
|
||||||
|
description: "Test Network",
|
||||||
|
rulesSource:
|
||||||
|
"\n# This is a default rule set that allows IPv4 and IPv6 traffic but otherwise\n# behaves like a standard Ethernet switch.\n\n#\n# Allow only IPv4, IPv4 ARP, and IPv6 Ethernet frames.\n#\ndrop\n not ethertype ipv4\n and not ethertype arp\n and not ethertype ipv6\n;\n\n#\n# Uncomment to drop non-ZeroTier issued and managed IP addresses.\n#\n# This prevents IP spoofing but also blocks manual IP management at the OS level and\n# bridging unless special rules to exempt certain hosts or traffic are added before\n# this rule.\n#\n#drop\n# not chr ipauth\n#;\n\n# Accept anything else. This is required since default is 'drop'.\naccept;\n",
|
||||||
|
tagsByName: {},
|
||||||
|
capabilitiesByName: {},
|
||||||
|
config: {
|
||||||
|
authTokens: [null],
|
||||||
|
authorizationEndpoint: "",
|
||||||
|
capabilities: [],
|
||||||
|
clientId: "",
|
||||||
|
creationTime: 1672676611179,
|
||||||
|
dns: [],
|
||||||
|
enableBroadcast: true,
|
||||||
|
id: "0d303702cd0f1fc6",
|
||||||
|
ipAssignmentPools: [
|
||||||
|
{
|
||||||
|
ipRangeEnd: "172.30.101.254",
|
||||||
|
ipRangeStart: "172.30.101.1",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
mtu: 2800,
|
||||||
|
multicastLimit: 32,
|
||||||
|
name: "new-net-11166",
|
||||||
|
nwid: "0d303702cd0f1fc6",
|
||||||
|
private: true,
|
||||||
|
routes: [
|
||||||
|
{
|
||||||
|
target: "172.30.101.0/24",
|
||||||
|
via: null,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
etherType: 2048,
|
||||||
|
not: true,
|
||||||
|
or: false,
|
||||||
|
type: "MATCH_ETHERTYPE",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
etherType: 2054,
|
||||||
|
not: true,
|
||||||
|
or: false,
|
||||||
|
type: "MATCH_ETHERTYPE",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
etherType: 34525,
|
||||||
|
not: true,
|
||||||
|
or: false,
|
||||||
|
type: "MATCH_ETHERTYPE",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "ACTION_DROP",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "ACTION_ACCEPT",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
ssoEnabled: false,
|
||||||
|
tags: [],
|
||||||
|
v4AssignMode: {
|
||||||
|
zt: true,
|
||||||
|
},
|
||||||
|
v6AssignMode: {
|
||||||
|
"6plane": false,
|
||||||
|
rfc4193: false,
|
||||||
|
zt: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("NetworkHeader", () => {
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,28 @@
|
||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`renders HomeLoggedOut unchanged 1`] = `
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
class="MuiGrid-root MuiGrid-item"
|
||||||
|
>
|
||||||
|
<h5
|
||||||
|
class="MuiTypography-root MuiTypography-h5"
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
0d303702cd0f1fc6
|
||||||
|
</span>
|
||||||
|
</h5>
|
||||||
|
<h6
|
||||||
|
class="MuiTypography-root MuiTypography-h6"
|
||||||
|
style="font-style: italic;"
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
new-net-11166
|
||||||
|
</span>
|
||||||
|
</h6>
|
||||||
|
<span>
|
||||||
|
Test Network
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
Loading…
Add table
Add a link
Reference in a new issue