ultisuite-client/lib/drive/docs-graphic-image-size.test.ts
R3D347HR4Y 303b2b1074
Some checks are pending
E2E / Playwright e2e (push) Waiting to run
wow
2026-06-11 01:22:40 +02:00

32 lines
1.1 KiB
TypeScript

import assert from "node:assert/strict"
import { describe, it } from "node:test"
import { computeImageInsertFrameSize } from "./docs-graphic-image-size.ts"
describe("docs-graphic-image-size", () => {
it("preserves aspect ratio for landscape images", () => {
const frame = computeImageInsertFrameSize(1920, 1080)
assert.equal(frame.width, 560)
assert.equal(frame.height, 315)
assert.ok(Math.abs(frame.width / frame.height - 1920 / 1080) < 0.02)
})
it("preserves aspect ratio for portrait images", () => {
const frame = computeImageInsertFrameSize(1080, 1920)
assert.equal(frame.height, 720)
assert.equal(frame.width, 405)
assert.ok(Math.abs(frame.width / frame.height - 1080 / 1920) < 0.02)
})
it("keeps small images at natural size", () => {
const frame = computeImageInsertFrameSize(200, 150)
assert.equal(frame.width, 200)
assert.equal(frame.height, 150)
})
it("falls back when natural size is invalid", () => {
const frame = computeImageInsertFrameSize(0, 0)
assert.equal(frame.width, 240)
assert.equal(frame.height, 160)
})
})