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>
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { defaultForMeta, type CameraLensDefault } from './lensDefaults';
|
||||
import type { LensProfile } from '../types';
|
||||
|
||||
const profile = (model: string): LensProfile => ({
|
||||
maker: 'Nikon',
|
||||
model,
|
||||
crop: 1,
|
||||
corrections: { distortion: true, tca: true, vignetting: true },
|
||||
});
|
||||
|
||||
const savedDefault = (
|
||||
camera: string,
|
||||
exifLens: string,
|
||||
model = 'Nikkor AF 50mm f/1.8D',
|
||||
): CameraLensDefault => ({
|
||||
camera,
|
||||
exifLens,
|
||||
profile: profile(model),
|
||||
updatedAt: Date.now(),
|
||||
});
|
||||
|
||||
describe('camera-lens default selection', () => {
|
||||
it('matches a camera and lens after normalizing both names', () => {
|
||||
const defaults = [
|
||||
savedDefault('NIKON CORPORATION NIKON D700', 'NIKON AF NIKKOR 50MM F/1.8D'),
|
||||
];
|
||||
expect(
|
||||
defaultForMeta(defaults, {
|
||||
camera: 'NIKON D700',
|
||||
lens: 'Nikkor AF 50mm 1:1.8D',
|
||||
}),
|
||||
).toBe(defaults[0]);
|
||||
});
|
||||
|
||||
it('does not apply a default to a different lens on the same body', () => {
|
||||
const defaults = [
|
||||
savedDefault('NIKON CORPORATION NIKON D700', 'NIKON AF NIKKOR 50MM F/1.8D'),
|
||||
];
|
||||
expect(
|
||||
defaultForMeta(defaults, {
|
||||
camera: 'NIKON CORPORATION NIKON D700',
|
||||
lens: 'NIKON AF NIKKOR 85MM F/1.8G',
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it('requires both camera and lens metadata', () => {
|
||||
const defaults = [
|
||||
savedDefault('NIKON CORPORATION NIKON D700', 'NIKON AF NIKKOR 50MM F/1.8D'),
|
||||
];
|
||||
expect(defaultForMeta(defaults, { camera: 'NIKON D700', lens: undefined })).toBeNull();
|
||||
expect(defaultForMeta(defaults, { camera: undefined, lens: 'NIKKOR 50mm f/1.8D' })).toBeNull();
|
||||
});
|
||||
|
||||
it('uses the first row when more than one entry has the same key', () => {
|
||||
const older = { ...savedDefault('NIKON D700', 'NIKKOR 50mm f/1.8D'), updatedAt: 1 };
|
||||
const newer = { ...savedDefault('NIKON D700', 'NIKON AF NIKKOR 50MM F/1.8D'), updatedAt: 2 };
|
||||
expect(
|
||||
defaultForMeta([newer, older], {
|
||||
camera: 'NIKON CORPORATION NIKON D700',
|
||||
lens: 'Nikkor AF 50mm f/1.8D',
|
||||
}),
|
||||
).toBe(newer);
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user