import assert from 'node:assert/strict'; import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; import test from 'node:test'; import { readPresentationSettings, writePresentationSettings } from './appPreferences'; void test('appPreferences: presentation settings round-trip without clobbering eula', () => { const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'dnd-prefs-')); const prefsPath = path.join(dir, 'preferences.json'); fs.writeFileSync(prefsPath, `${JSON.stringify({ eulaAcceptedVersion: 2 }, null, 2)}\n`, 'utf8'); writePresentationSettings(dir, { displayId: 42, fullScreen: false }); const loaded = readPresentationSettings(dir); assert.equal(loaded.displayId, 42); assert.equal(loaded.fullScreen, false); const raw = JSON.parse(fs.readFileSync(prefsPath, 'utf8')) as { eulaAcceptedVersion?: number; presentation?: { displayId: number | null; fullScreen: boolean }; }; assert.equal(raw.eulaAcceptedVersion, 2); assert.equal(raw.presentation?.displayId, 42); assert.equal(raw.presentation?.fullScreen, false); }); void test('appPreferences: defaults when preferences missing', () => { const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'dnd-prefs-')); const loaded = readPresentationSettings(dir); assert.equal(loaded.displayId, null); assert.equal(loaded.fullScreen, true); });