import { describe, expect, it } from "vitest";
import { mergeSettings, setDefinitionPaused } from "../src/shared/settings";
import { DEFAULT_SETTINGS } from "../src/shared/types";

describe("definition pause settings", () => {
  it("adds and removes a definition ID without disturbing other settings", () => {
    const settings = setDefinitionPaused({ ...DEFAULT_SETTINGS, threshold: .65 }, "mastodon", true);
    expect(settings.disabledDefinitionIds).toEqual(["mastodon"]);
    expect(settings.threshold).toBe(.65);

    const resumed = setDefinitionPaused(settings, "mastodon", false);
    expect(resumed.disabledDefinitionIds).toEqual([]);
    expect(resumed.threshold).toBe(.65);
  });

  it("does not duplicate an already paused definition", () => {
    const settings = setDefinitionPaused({ ...DEFAULT_SETTINGS, disabledDefinitionIds: ["mastodon"] }, "mastodon", true);
    expect(settings.disabledDefinitionIds).toEqual(["mastodon"]);
  });
});

describe("legacy settings", () => {
  it("removes legacy inference settings", () => {
    expect(mergeSettings({ cpuThreads: 99 })).not.toHaveProperty("cpuThreads");
    expect(mergeSettings({ inferenceDevice: "webgpu" } as never)).not.toHaveProperty("inferenceDevice");
  });
});
