/**
 * preferences-verification-auto-defer.test.mjs — threshold preference contract.
 *
 * Purpose: ensure the auto-defer verification threshold survives preference
 * validation instead of being silently dropped before autonomous verification.
 */
import assert from "node:assert/strict";
import { test } from "vitest";
import { validatePreferences } from "../preferences-validation.js";

test("validatePreferences_when_auto_defer_threshold_is_between_zero_and_one_keeps_value", () => {
	const result = validatePreferences({
		verification_auto_defer_threshold: 0.65,
	});

	assert.deepEqual(result.errors, []);
	assert.equal(result.preferences.verification_auto_defer_threshold, 0.65);
});

test("validatePreferences_when_auto_defer_threshold_is_out_of_range_reports_error", () => {
	const result = validatePreferences({
		verification_auto_defer_threshold: 1.5,
	});

	assert.equal(result.preferences.verification_auto_defer_threshold, undefined);
	assert.deepEqual(result.errors, [
		"verification_auto_defer_threshold must be a number between 0 and 1",
	]);
});
