import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { test } from "vitest";

const extensionSource = readFileSync(
	join(process.cwd(), "vscode-extension", "src", "extension.ts"),
	"utf-8",
);

test("VS Code startup uses inspected global/default config for binary path and auto-start", () => {
	assert.match(extensionSource, /inspect<T>\(key\)/);
	assert.match(extensionSource, /globalValue \?\? inspected\?\.defaultValue/);
	assert.match(
		extensionSource,
		/binaryPath:\s*getTrustedConfigurationValue\("sf",\s*"binaryPath",\s*"sf"\)/,
	);
	assert.match(
		extensionSource,
		/autoStart:\s*getTrustedConfigurationValue\("sf",\s*"autoStart",\s*false\)/,
	);
	assert.doesNotMatch(extensionSource, /config\.get<string>\("binaryPath"/);
	assert.doesNotMatch(extensionSource, /config\.get<boolean>\("autoStart"/);
});
