mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Adding <PodTolerations/> tests
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
96beb0f2d9
commit
b5fad97519
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import "@testing-library/jest-dom/extend-expect";
|
||||
import { fireEvent, render } from "@testing-library/react";
|
||||
import { IToleration } from "../../../api/workload-kube-object";
|
||||
import { PodTolerations } from "../pod-tolerations";
|
||||
|
||||
const tolerations: IToleration[] =[
|
||||
{
|
||||
key: "CriticalAddonsOnly",
|
||||
operator: "Exist",
|
||||
effect: "NoExecute",
|
||||
tolerationSeconds: 3600
|
||||
},
|
||||
{
|
||||
key: "node.kubernetes.io/not-ready",
|
||||
operator: "NoExist",
|
||||
effect: "NoSchedule",
|
||||
tolerationSeconds: 7200
|
||||
},
|
||||
];
|
||||
|
||||
describe("<PodTolerations />", () => {
|
||||
it("renders w/o errors", () => {
|
||||
const { container } = render(<PodTolerations tolerations={tolerations} />);
|
||||
|
||||
expect(container).toBeInstanceOf(HTMLElement);
|
||||
});
|
||||
|
||||
it("shows all tolerations", () => {
|
||||
const { container } = render(<PodTolerations tolerations={tolerations} />);
|
||||
const rows = container.querySelectorAll(".TableRow");
|
||||
|
||||
expect(rows[0].querySelector(".key").textContent).toBe("CriticalAddonsOnly");
|
||||
expect(rows[0].querySelector(".operator").textContent).toBe("Exist");
|
||||
expect(rows[0].querySelector(".effect").textContent).toBe("NoExecute");
|
||||
expect(rows[0].querySelector(".seconds").textContent).toBe("3600");
|
||||
|
||||
expect(rows[1].querySelector(".key").textContent).toBe("node.kubernetes.io/not-ready");
|
||||
expect(rows[1].querySelector(".operator").textContent).toBe("NoExist");
|
||||
expect(rows[1].querySelector(".effect").textContent).toBe("NoSchedule");
|
||||
expect(rows[1].querySelector(".seconds").textContent).toBe("7200");
|
||||
});
|
||||
|
||||
it("sorts table properly", () => {
|
||||
const { container, getByText } = render(<PodTolerations tolerations={tolerations} />);
|
||||
const headCell = getByText("Key");
|
||||
|
||||
fireEvent.click(headCell);
|
||||
fireEvent.click(headCell);
|
||||
|
||||
const rows = container.querySelectorAll(".TableRow");
|
||||
|
||||
expect(rows[0].querySelector(".key").textContent).toBe("node.kubernetes.io/not-ready");
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user