import { beforeEach, describe, expect, it, vi } from "vitest";

const mockPost = vi.fn();

vi.mock("./client", () => ({
	apiClient: {
		post: (...args: unknown[]) => mockPost(...args),
	},
}));

import { refreshConfigProfileGitMounts } from "./config-profiles";

describe("refreshConfigProfileGitMounts", () => {
	beforeEach(() => {
		mockPost.mockReset();
	});

	it("confirms the destructive refresh at the API boundary", async () => {
		mockPost.mockResolvedValue({ data: { refresh_outcomes: [] } });

		await expect(refreshConfigProfileGitMounts("profile-1")).resolves.toEqual({
			refresh_outcomes: [],
		});

		expect(mockPost).toHaveBeenCalledWith(
		"/config-profiles/profile-1/refresh-git-mounts",
		undefined,
		{ params: { confirm_destructive_refresh: true } },
	);
	});
});
