import { describe, expect, it } from "vitest";
import { shouldRotateFlockSession } from "@/workers/rpa/flock/worker-session";

describe("shouldRotateFlockSession", () => {
  it("注册被拒时轮换", () => {
    expect(
      shouldRotateFlockSession("FLOCK_ACCOUNT_REJECTED: We had an issue creating your account"),
    ).toBe(true);
  });

  it("邮箱已存在时轮换", () => {
    expect(shouldRotateFlockSession("FLOCK_ACCOUNT_EXISTS: already registered")).toBe(
      true,
    );
  });

  it("报价上限时轮换", () => {
    expect(
      shouldRotateFlockSession(
        "FLOCK_QUOTE_LIMIT：官网提示 Thank you for your interest（获取报价已达上限）",
      ),
    ).toBe(false);
  });

  it("普通报价失败不轮换", () => {
    expect(shouldRotateFlockSession("RPA_DATA_INVALID：20s 内未拿到报价")).toBe(false);
  });
});
