1import assert from 'node:assert/strict';2import test from 'node:test';34import { fitStreamSurface } from './window-geometry.mjs';56test('stream surface scales above native resolution without changing aspect ratio', () => {7 assert.deepEqual(fitStreamSurface({8 frameWidth: 1280,9 frameHeight: 800,10 availableWidth: 1920,11 availableHeight: 1200,12 }), { width: 1920, height: 1200 });1314 assert.deepEqual(fitStreamSurface({15 frameWidth: 1280,16 frameHeight: 800,17 availableWidth: 1920,18 availableHeight: 1080,19 }), { width: 1728, height: 1080 });20});2122test('arbitrary portrait and ultrawide host resolutions letterbox inside user bounds', () => {23 assert.deepEqual(fitStreamSurface({24 frameWidth: 800,25 frameHeight: 1280,26 availableWidth: 1920,27 availableHeight: 1080,28 }), { width: 675, height: 1080 });2930 assert.deepEqual(fitStreamSurface({31 frameWidth: 3440,32 frameHeight: 1440,33 availableWidth: 1200,34 availableHeight: 900,35 }), { width: 1200, height: 502 });36});3738test('malformed dimensions fail closed before changing the surface', () => {39 assert.throws(() => fitStreamSurface({40 frameWidth: 0,41 frameHeight: 800,42 availableWidth: 1920,43 availableHeight: 1080,44 }), /frame width/);45 assert.throws(() => fitStreamSurface({46 frameWidth: 1280,47 frameHeight: 800,48 availableWidth: Number.NaN,49 availableHeight: 1080,50 }), /available surface width/);51});