Files
luminary/src/lib/editSections.test.ts
T
bhursey cd52a2f82f Initial commit: Luminary photo catalog and RAW editor
Browser-based photo catalog with an optional team server (SQLite + LibRaw).
Local database, uploaded photos, build output and dependencies are gitignored.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-23 15:19:25 +00:00

72 lines
2.4 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { defaultEdits, defaultLocalLayer } from './edits';
import { applyEditSections } from './editSections';
import { autoNoiseFor } from './noiseProfile';
describe('applyEditSections', () => {
it('copies only the selected panel groups', () => {
const source = defaultEdits();
source.exposure = 1.25;
source.saturation = 18;
source.crop = { ...source.crop, x: 0.1, w: 0.7 };
const target = defaultEdits();
target.crop = { ...target.crop, x: 0.4, w: 0.2 };
const next = applyEditSections(source, target, ['light']);
expect(next.exposure).toBe(1.25);
expect(next.saturation).toBe(18);
expect(next.crop.x).toBe(0.4);
expect(next.crop.w).toBe(0.2);
});
it('does not mutate either edit record', () => {
const source = defaultEdits();
source.exposure = 2;
const target = defaultEdits();
applyEditSections(source, target, ['light']);
expect(source.exposure).toBe(2);
expect(target.exposure).toBe(0);
});
it('can copy crop and local masks separately', () => {
const source = defaultEdits();
source.crop = { ...source.crop, angle: 4.5 };
source.local = [
{
...defaultLocalLayer('radial', 0),
id: 'mask-1',
name: 'Face',
},
];
const target = defaultEdits();
const cropped = applyEditSections(source, target, ['crop']);
expect(cropped.crop.angle).toBe(4.5);
expect(cropped.local).toHaveLength(0);
const masked = applyEditSections(source, target, ['local']);
expect(masked.local[0].name).toBe('Face');
expect(masked.crop.angle).toBe(0);
});
});
describe('autoNoiseFor', () => {
it('raises luminance and chroma smoothing with ISO', () => {
const low = autoNoiseFor({ iso: 100 });
const high = autoNoiseFor({ iso: 6400 });
expect(high.luminance).toBeGreaterThan(low.luminance);
expect(high.chroma).toBeGreaterThan(low.chroma);
expect(high.detail).toBeLessThanOrEqual(low.detail);
});
it('keeps every slider inside the editor range', () => {
const noise = autoNoiseFor({ iso: 204800 });
expect(noise.luminance).toBeGreaterThanOrEqual(0);
expect(noise.luminance).toBeLessThanOrEqual(100);
expect(noise.chroma).toBeGreaterThanOrEqual(0);
expect(noise.chroma).toBeLessThanOrEqual(100);
expect(noise.detail).toBeGreaterThanOrEqual(0);
expect(noise.chromaDetail).toBeLessThanOrEqual(100);
});
});