import assert from "node:assert/strict";
import { describe, it } from "vitest";
import type { Model } from "../types.js";
import { isAutoReasoning, resolveReasoningLevel } from "./simple-options.js";

function createModel(overrides: Partial<Model<any>> = {}): Model<any> {
	return {
		id: "test-model",
		name: "Test Model",
		provider: "openai",
		api: "openai-responses",
		baseUrl: "https://api.openai.com/v1",
		contextWindow: 128_000,
		maxTokens: 16_384,
		input: ["text"],
		reasoning: true,
		cost: {
			input: 0,
			output: 0,
			cacheRead: 0,
			cacheWrite: 0,
		},
		...overrides,
	};
}

describe("simple-options reasoning helpers", () => {
	it("recognizes auto reasoning requests", () => {
		assert.equal(isAutoReasoning("auto"), true);
		assert.equal(isAutoReasoning("medium"), false);
		assert.equal(isAutoReasoning(undefined), false);
	});

	it("maps auto to medium for reasoning-capable models", () => {
		assert.equal(resolveReasoningLevel(createModel(), "auto"), "medium");
	});

	it("maps auto to undefined for models without reasoning support", () => {
		assert.equal(
			resolveReasoningLevel(createModel({ reasoning: false }), "auto"),
			undefined,
		);
	});

	it("passes through explicit reasoning levels unchanged", () => {
		assert.equal(resolveReasoningLevel(createModel(), "xhigh"), "xhigh");
	});
});
