import { describe, expect, it } from "vitest";
import { twoFactorRequest } from "./two-factor-request";

describe("twoFactorRequest", () => {
  it("creates when the user has no account configuration yet", () => {
    expect(twoFactorRequest(undefined, true)).toEqual({
      url: "/account-configurations/set-my-config",
      method: "POST",
      body: { isMFARequired: true },
    });
  });

  it("updates an existing record instead of creating a second one", () => {
    const config = { id: "c9fc67c6", isMFARequired: true };

    expect(twoFactorRequest(config, false)).toEqual({
      url: "/account-configurations/my-config/c9fc67c6",
      method: "PUT",
      body: { isMFARequired: false },
    });
  });
});
