import test from 'node:test' import assert from 'node:assert/strict' import {pickDefaultResolution, ehThumbnailUrl} from '../src/utils/thumbnail.js' test('original resolution wins whenever it is offered', () => { assert.equal(pickDefaultResolution({ '800x': '37.53MiB', '1280x': '66.57MiB', '2560x': '84.01MiB', 'Original': '498.2MiB' }), 'Original') }) test('without an original entry the largest file is chosen', () => { // 1920x is bigger than 2560x here, so byte size decides, not the label. assert.equal(pickDefaultResolution({ '800x': '37.53MiB', '1920x': '811.1MiB', '2560x': '84.01MiB' }), '1920x') }) test('an empty or missing resolution map yields an empty choice', () => { assert.equal(pickDefaultResolution({}), '') assert.equal(pickDefaultResolution(undefined), '') }) test('thumbnail urls carry the path and the active auth code', () => { const url = new URL(ehThumbnailUrl('https://example.org/t?a=1&b=2', 'code with spaces')) assert.equal(url.searchParams.get('path'), 'https://example.org/t?a=1&b=2') assert.equal(url.searchParams.get('AuthCode'), 'code with spaces') assert.equal(ehThumbnailUrl('', 'x'), '') })