test(frontend): auto-restore location stub in UserMenu tests

This commit is contained in:
Abhimanyu Saharan
2026-03-04 22:19:01 +05:30
parent b3b8285a64
commit 3a21c4c204

View File

@@ -4,7 +4,7 @@ import type {
PropsWithChildren,
ReactNode,
} from "react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
@@ -53,6 +53,9 @@ describe("UserMenu", () => {
clearLocalAuthTokenMock.mockReset();
isLocalAuthModeMock.mockReset();
});
afterEach(() => {
vi.unstubAllGlobals();
});
it("renders and opens local-mode menu actions", async () => {
const user = userEvent.setup();
@@ -91,6 +94,5 @@ describe("UserMenu", () => {
expect(clearLocalAuthTokenMock).toHaveBeenCalledTimes(1);
expect(reloadSpy).toHaveBeenCalledTimes(1);
vi.unstubAllGlobals();
});
});