Files
Genarrative/src/components/common/squareImageCropModel.test.ts
T
kdletters 071faa482c 统一 Rust 与 TypeScript 格式化门禁
纳入 AGC Cargo workspace 的统一 rustfmt 检查与格式化入口

完成项目 TypeScript/Prettier 与 Rust 全量格式化

修复 Pingora expected executable 门禁的空白敏感误报

同步开发运维文档与 AGC skill pack 格式化忽略规则
2026-09-01 16:28:34 +08:00

41 lines
786 B
TypeScript

import { expect, test } from 'vitest';
import {
buildCenteredSquareImageCropRect,
clampSquareImageCropRect,
} from './squareImageCropModel';
test('builds a centered square crop from a rectangular image', () => {
expect(
buildCenteredSquareImageCropRect({ width: 1200, height: 800 }),
).toEqual({
x: 200,
y: 0,
size: 800,
});
});
test('clamps square crop size and position inside image bounds', () => {
expect(
clampSquareImageCropRect(
{ width: 300, height: 200 },
{ x: 260, y: -30, size: 500 },
),
).toEqual({
x: 100,
y: 0,
size: 200,
});
expect(
clampSquareImageCropRect(
{ width: 300, height: 200 },
{ x: 120, y: 90, size: 10 },
),
).toEqual({
x: 120,
y: 90,
size: 48,
});
});