import { describe, expect, it } from 'vitest'; import { outputSize } from '../gl/renderer'; import { defaultEdits } from './edits'; import { buildFileName, DEFAULT_EXPORT } from './export'; import type { PhotoRecord } from '../types'; describe('export output dimensions', () => { it('matches the source for an uncropped image', () => { expect(outputSize(defaultEdits(), 6000, 4000)).toEqual({ w: 6000, h: 4000 }); }); it('swaps dimensions for a quarter turn', () => { const edits = defaultEdits(); edits.crop.quarter = 1; expect(outputSize(edits, 6000, 4000)).toEqual({ w: 4000, h: 6000 }); }); it('includes the triangular points added by straightening', () => { const edits = defaultEdits(); edits.crop.angle = 45; expect(outputSize(edits, 4000, 3000)).toEqual({ w: 4950, h: 4950 }); }); it('writes the JPEG XL extension for a JXL export', () => { const photo = { name: 'DSCF1234.RAF', addedAt: Date.now() } as PhotoRecord; const name = buildFileName('{name}', photo, 0, { ...DEFAULT_EXPORT, format: 'jxl' }); expect(name).toBe('DSCF1234.jxl'); }); it('applies the crop after the rotated frame is calculated', () => { const edits = defaultEdits(); edits.crop.angle = 45; edits.crop.w = 0.5; edits.crop.h = 0.5; expect(outputSize(edits, 4000, 3000)).toEqual({ w: 2475, h: 2475 }); }); });