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([
			["demo-flag", { type: "string" as const, allowNoValue: true }],
		]);
		const defaultFlagArgs = parseArgs(["--demo-flag"], extensionFlags);
		const explicitFlagArgs = parseArgs(["--demo-flag=8080"], extensionFlags);

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