import { describe, expect, it } from "vitest";
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);
const { isEnhancedEarlyROEnabled } = require("./rr-utils");

describe("server/rr/rr-utils", () => {
  it("keeps enhanced early ROs enabled when the shop setting is missing", () => {
    expect(isEnhancedEarlyROEnabled()).toBe(true);
    expect(isEnhancedEarlyROEnabled({})).toBe(true);
    expect(isEnhancedEarlyROEnabled({ md_functionality_toggles: {} })).toBe(true);
  });

  it("only disables enhanced early ROs when the shop explicitly opts out", () => {
    expect(isEnhancedEarlyROEnabled({ md_functionality_toggles: { enhanced_early_ros: false } })).toBe(false);
    expect(isEnhancedEarlyROEnabled({ md_functionality_toggles: { enhanced_early_ros: true } })).toBe(true);
  });
});
