import { afterEach, describe, expect, it, jest } from "@jest/globals";
import { flushPromises, mount } from "@vue/test-utils";
import MermaidCard from "../../../frontend/src/components/MermaidCard.vue";
import mermaid from "mermaid";
describe("MermaidCard", () => {
afterEach(() => {
jest.restoreAllMocks();
document.body.style.overflow = "";
});
it("renders diagrams and handles the fullscreen overlay lifecycle", async () => {
const initSpy = jest.spyOn(mermaid, "initialize");
const renderSpy = jest.spyOn(mermaid, "render").mockResolvedValue({
svg: "",
});
const wrapper = mount(MermaidCard, {
props: {
title: "Network",
description: "Topology",
diagram: "graph TD;A-->B;",
cardId: "network-card",
},
});
await flushPromises();
expect(initSpy).toHaveBeenCalledTimes(1);
expect(renderSpy).toHaveBeenCalled();
expect(wrapper.html()).toContain("