Files
lasercut-scrap-modeller/tests/load-image.test.ts
T

17 lines
563 B
TypeScript

import { describe, expect, it } from 'vitest';
import { fitSize, MAX_SIDE } from '../src/lib/load-image';
describe('fitSize', () => {
it('downscales a 12 MP landscape photo to the max side', () => {
expect(fitSize(4000, 3000, MAX_SIDE)).toEqual({ width: 2000, height: 1500 });
});
it('downscales portrait photos by their height', () => {
expect(fitSize(3024, 4032, 2000)).toEqual({ width: 1500, height: 2000 });
});
it('never upscales small images', () => {
expect(fitSize(800, 600, 2000)).toEqual({ width: 800, height: 600 });
});
});