test: cover services + bookmarks group components

This commit is contained in:
shamoon
2026-02-04 08:24:34 -08:00
parent f9a93d77a2
commit 0cb50794fa
10 changed files with 592 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
// @vitest-environment jsdom
import { render, screen } from "@testing-library/react";
import { beforeEach, describe, expect, it, vi } from "vitest";
const { useSWR } = vi.hoisted(() => ({ useSWR: vi.fn() }));
vi.mock("swr", () => ({
default: useSWR,
}));
import ProxmoxStatus from "./proxmox-status";
describe("components/services/proxmox-status", () => {
beforeEach(() => {
vi.clearAllMocks();
});
it("requests vm stats and renders running when status is running", () => {
useSWR.mockReturnValue({ data: { status: "running" }, error: undefined });
render(<ProxmoxStatus service={{ proxmoxNode: "n1", proxmoxVMID: "100" }} />);
expect(useSWR).toHaveBeenCalledWith("/api/proxmox/stats/n1/100?type=qemu");
expect(screen.getByText("docker.running")).toBeInTheDocument();
});
it("renders paused for paused vms", () => {
useSWR.mockReturnValue({ data: { status: "paused" }, error: undefined });
render(<ProxmoxStatus service={{ proxmoxNode: "n1", proxmoxVMID: "100", proxmoxType: "lxc" }} />);
expect(useSWR).toHaveBeenCalledWith("/api/proxmox/stats/n1/100?type=lxc");
expect(screen.getByText("paused")).toBeInTheDocument();
});
});