import assert from 'node:assert/strict'; import { readFile } from 'node:fs/promises'; import { test } from 'node:test'; const html = await readFile(new URL('../index.html', import.meta.url), 'utf8'); const range = id => { const input = html.match(new RegExp(`]*\\bid="${id}"[^>]*>`))?.[0]; assert.ok(input, `${id} is a real HTML input`); return Object.fromEntries([...input.matchAll(/([\w-]+)="([^"]*)"/g)].map(([, key, value]) => [key, value])); }; test('photo distance defaults to 16 within the original 0–21 percent range', () => { const input = range('photo-glass-distance'); assert.deepEqual([input.type, input.min, input.max, input.step, input.value], ['range', '0', '21', '1', '16']); assert.match(html, /16%<\/output>/); assert.doesNotMatch(html, /100% 멀어짐/); }); test('camera offset exposes 0.35–0.90 with the gentler 0.75 default', () => { const input = range('camera-offset'); assert.deepEqual([input.type, input.min, input.max, input.step, input.value], ['range', '0.35', '0.90', '0.01', '0.75']); }); test('curvature offers exactly convex and concave with convex selected', () => { const select = html.match(/]*\bid="curvature"[^>]*>([\s\S]*?)<\/select>/)?.[1]; assert.ok(select, 'curvature is a select rather than a continuous slider'); const options = [...select.matchAll(/]*)>([^<]*)<\/option>/g)]; assert.equal(options.length, 2); assert.deepEqual(options.map(([, attrs, label]) => [attrs.match(/value="([^"]+)"/)?.[1], label]), [['1', '볼록'], ['-1', '오목']]); assert.match(options[0][1], /\bselected\b/); assert.doesNotMatch(options[1][1], /\bselected\b/); assert.doesNotMatch(html, /id="curvatureOut"/); }); test('the gloss slider and its output are removed from the DOM', () => { assert.doesNotMatch(html, /id="gloss-strength"|id="glossOut"/); });