import assert from "node:assert/strict";
import { describe, it } from "vitest";
import { parseArgs } from "./args.js";

describe("parseArgs", () => {
	it("parses optional-value extension flags with implicit and explicit values", () => {
		const extensionFlags = new Map([
			["genai-proxy", { type: "string" as const, allowNoValue: true }],
		]);
		const defaultFlagArgs = parseArgs(["--genai-proxy"], extensionFlags);
		const explicitFlagArgs = parseArgs(["--genai-proxy=8080"], extensionFlags);

		assert.deepEqual(
			[
				defaultFlagArgs.unknownFlags.get("genai-proxy"),
				explicitFlagArgs.unknownFlags.get("genai-proxy"),
			],
			[true, "8080"],
		);
	});
});
